Search code examples
wpfxamldefaultinternal

Change default FieldModifier for XAML,WPF


The default FieldModifier value in WPF when using XAML is "internal", unless explicitly stated, e.g.

<Button x:FieldModifier="private" Name="BackButton" Content="Hello stackoverflow"/>

Is there any way to change this default, so that it is no longer necessary to define x:FieldModifier for every single element?


Solution

  • No. It is part of the WPF/XAML specification and implemented in the XAML Parser. It is similar to how private is the default scope within a class and internal within a namespace.