ContentPropertyAttribute 类

定义

指示用作 XAML 中内容属性的属性。

public ref class ContentPropertyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
public sealed class ContentPropertyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)>]
type ContentPropertyAttribute = class
    inherit Attribute
Public NotInheritable Class ContentPropertyAttribute
Inherits 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

获取内容属性的名称。

适用于