ContentControl.ContentTemplate 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置用于显示该 ContentControl数据内容的数据模板。
public:
property System::Windows::DataTemplate ^ ContentTemplate { System::Windows::DataTemplate ^ get(); void set(System::Windows::DataTemplate ^ value); };
[System.ComponentModel.Bindable(true)]
public System.Windows.DataTemplate ContentTemplate { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.ContentTemplate : System.Windows.DataTemplate with get, set
Public Property ContentTemplate As DataTemplate
属性值
数据模板。 默认值为 null。
- 属性
示例
以下示例演示如何创建内容模板并将模板应用于内容控件。
<DataTemplate x:Key="template1">
<TextBlock Text="{Binding}" FontSize="12" FontWeight="Bold" TextWrapping="Wrap"></TextBlock>
</DataTemplate>
<ContentControl Name="contCtrl" ContentTemplate="{StaticResource template1}"
Content="This is the content of the content control."/>
注解
将此属性设置为 a DataTemplate 以指定 .. 的外观 ContentControl。 有关数据模板的详细信息,请参阅 数据模板化概述。
XAML 属性用法
<object ContentTemplate="{resourceExtension styleResourceKey}"/>
XAML 值
resourceExtension 一个标记扩展,用于标识如何引用模板资源 StaticResource 或 DynamicResource. 请参阅 XAML 资源。
styleResourceKey 标识请求的模板选择器的键。 键是指 .. 中的 ResourceDictionary现有资源。
注释
属性元素语法在技术上是可能的,但不建议这样做。 有关详细信息,请参阅 内联样式和模板。
Dependency 属性信息
| 物品 | 价值 |
|---|---|
| 标识符字段 | ContentTemplateProperty |
元数据属性设置为 true |
没有 |