diff --git a/src/Controls/src/Core/ContentConverter.cs b/src/Controls/src/Core/ContentConverter.cs index 50d76aa70245..e94554ddcb6c 100644 --- a/src/Controls/src/Core/ContentConverter.cs +++ b/src/Controls/src/Core/ContentConverter.cs @@ -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 } }; + } } } }