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."/>
注釈
このプロパティを DataTemplate に設定して、 ContentControlの外観を指定します。 データ テンプレートの詳細については、「 データ テンプレートの概要」を参照してください。
XAML 属性の使用法
<object ContentTemplate="{resourceExtension styleResourceKey}"/>
XAML 値
resourceExtension テンプレート リソースを参照する方法を識別するマークアップ拡張機能 ( StaticResource または DynamicResource)。
「XAML リソース」を参照してください。
styleResourceKey 要求されたテンプレート セレクターを識別するキー。 キーは、 ResourceDictionary内の既存のリソースを参照します。
Note
プロパティ要素の構文は技術的には可能ですが、推奨されません。 詳細については、「 インライン スタイルとテンプレート」を参照してください。
依存関係プロパティ情報
| 品目 | 価値 |
|---|---|
| 識別子フィールド | ContentTemplateProperty |
に設定されたメタデータ プロパティ true |
なし |