다음을 통해 공유


x:ClassModifier Attribute

Modifies XAML compilation behavior in cases where x:Class is also provided. Specifically, instead of creating a partial class with a Public access level (the default), the provided x:Class is created with a NonPublic access value. This affects the access level for the class in the generated assemblies.

XAML Attribute Usage

<object x:Class="namespace.classname" x:ClassModifier="NonPublic">
   ...
</object>

XAML Values

NonPublic

The exact string to pass to specifiy Public versus NonPublic varies, depending on the code-behind programming language being used. See Remarks.

Dependencies

x:Class Attribute must also be provided on the same element, and that element must be the root element in a page.

Remarks

The value for the x:ClassModifier attribute will vary by programming language. The string to use will depend on how each language implements its CodeDomProvider and the type converters it returns to define the meanings for TypeAttributes.Public and TypeAttributes.NonPublic, and whether that language is case sensitive or not.

  • For C#, the string to pass to designate NonPublic is internal.

  • For Microsoft Visual Basic .NET, the string to pass to designate NonPublic is Friend.

  • For C++/CLI, the C++/CLI targets do not currently support compiling XAML.

You can also specify Public (public in C#, Public in Microsoft Visual Basic .NET) but that is uncommon, because Public as the behavior is already the default.

See Also

Reference

x:Class Attribute
x:FieldModifier Attribute

Concepts

Code-Behind and XAML