Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/Controls/src/Core/ContentConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,21 @@ static bool HasTemplateAncestor(ContentPresenter presenter, Type type)

return false;
}
}

// Internal label type used by ContentPresenter to avoid interference from global Label styles.
// MAUI resolves implicit styles by looking up Type.FullName as the key in ResourceDictionary,
// starting from the element's own Resources and walking up the visual tree (see MergedStyle.RegisterImplicitStyles).
// By storing an empty Style keyed to typeof(ContentLabel).FullName in the element's own Resources,
// the lookup finds it locally and short-circuits — the global Label style (even with ApplyToDerivedTypes)
// is never reached. This keeps properties like TextColor unset, so ShouldSetBinding returns true
// and the binding to the templated parent (e.g. RadioButton.TextColor) can be established.
internal class ContentLabel : Label
{
static readonly Style s_style = new Style(typeof(ContentLabel));
public ContentLabel()
// Internal label type used by ContentPresenter to avoid interference from global Label styles.
// MAUI resolves implicit styles by looking up Type.FullName as the key in ResourceDictionary,
// starting from the element's own Resources and walking up the visual tree (see MergedStyle.RegisterImplicitStyles).
// By storing an empty Style keyed to typeof(ContentLabel).FullName in the element's own Resources,
// the lookup finds it locally and short-circuits — the global Label style (even with ApplyToDerivedTypes)
// is never reached. This keeps properties like TextColor unset, so ShouldSetBinding returns true
// and the binding to the templated parent (e.g. RadioButton.TextColor) can be established.
class ContentLabel : Label
{
Resources = new ResourceDictionary { { typeof(ContentLabel).FullName, s_style } };
static readonly Style s_style = new Style(typeof(ContentLabel));
public ContentLabel()
{
Resources = new ResourceDictionary { { typeof(ContentLabel).FullName, s_style } };
}
}
}
}
Loading