ContentPropertyAttribute 类

定义

指示作为(默认)内容属性的类型的属性。

[System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)]
public sealed class ContentPropertyAttribute : Attribute
type ContentPropertyAttribute = class
    inherit Attribute
继承
ContentPropertyAttribute
属性

注解

XAML 处理器使用 来确定内容属性。

使用 ContentPropertyAttribute 修饰类型允许更短的 XAML 语法。 As

ContentView已应用 ContentProperty 特性,此 XAML 有效:
<ContentView>
<Label Text="Hello, Forms"/>
</ContentView>

这等效于以下更明确的 XAML

<ContentView>
<ContentView.Content>
<Label Text="Hello, Forms"/>
</ContentView.Content>
</ContentView>

构造函数

ContentPropertyAttribute(String)

初始化 ContentPropertyAttribute 类的新实例。

属性

Name

获取内容属性的名称

适用于