مشاركة عبر


ContentControl.ContentTemplate Property

Definition

Gets or sets the data template that is used to display the content of the ContentControl.

DataTemplate ContentTemplate();

void ContentTemplate(DataTemplate value);
public DataTemplate ContentTemplate { get; set; }
var dataTemplate = contentControl.contentTemplate;
contentControl.contentTemplate = dataTemplate;
Public Property ContentTemplate As DataTemplate
<contentControl>
  <contentControl.ContentTemplate>
    dataTemplate
  </contentControl.ContentTemplate>
</contentControl>
- or -
<contentControl ContentTemplate="templateReference"/>

Property Value

The data template that is used to display the content of the ContentControl.

Remarks

Instead of declaring a fixed DataTemplate, you can also implement a DataTemplateSelector and use it to set the ContentTemplateSelector property. This technique enables custom template switching based on input data, at the application level. For more information, see DataTemplateSelector.

Applies to