Edit

x:FieldModifier attribute

Modifies XAML compilation behavior, such that fields for named object references are defined with public access rather than the private default behavior.

Note

C# and C++/WinRT are supported for both WinUI 3 / Windows App SDK and UWP apps. C++/CX applies to UWP only, and isn't supported for WinUI 3.

XAML attribute usage

<object x:FieldModifier="public".../>

Dependencies

x:Name attribute must also be provided on the same element.

Remarks

The value for the x:FieldModifier attribute will vary by programming language. Valid values are private, public, protected, internal or friend. For C# or Visual C++ component extensions (C++/CX), you can give the string value "public" or "Public"; the parser doesn't enforce case on this attribute value.

Private access is the default.

x:FieldModifier is only relevant for elements with an x:Name attribute, because that name is used to reference the field once it is public.

Note

Windows Runtime XAML doesn't support x:ClassModifier or x:Subclass.