x:FieldModifier 属性x:FieldModifier attribute

修改 XAML 编译行为,使指定对象引用的字段被定义有 public 访问权限而不是默认的 private 行为。Modifies XAML compilation behavior, such that fields for named object references are defined with public access rather than the private default behavior.

XAML 属性使用方法XAML attribute usage

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


x:Name 属性还必须在同一元素上进行提供。x:Name attribute must also be provided on the same element.


x:FieldModifier 属性的值将随编程语言而变。The value for the x:FieldModifier attribute will vary by programming language. 有效值为 privatepublicprotectedinternalfriendValid values are private, public, protected, internal or friend. 有关C#,Microsoft Visual Basic 或 Visual c + + 组件扩展 (C + + /cli CX),可以将该字符串指定值"public"Public";分析器不会强制执行上此属性的值的用例。For C#, Microsoft Visual Basic 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 访问权限是默认设置。Private access is the default.

x:FieldModifier 仅适合具有 x:Name 属性的元素,因为一旦该名称是公共的,它将用来引用字段。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.

请注意  不支持 Windows 运行时 XAML X:classmodifierx: 子类Note  Windows Runtime XAML doesn't support x:ClassModifier or x:Subclass.