Later in our project will be a large number of templates, mainly refers to the space template, the data template will be used relatively little, below I want to introduce the control template and data template, I see a great god written relatively good, I tidied up, so that we can better understand, for everyone to reference,
First introduce DataTemplate
DataTemplate: Is the performance of the data content, a piece of data shows what it looks like
1. The data template is commonly used in the following places:
- The ContentTemplate property of the ContentControl.
- The ItemTemplate property of the ItemsControl.
- The CellTemplate property of the Gridviewcolumn.
2. Example
ContentControl
ItemsControl
ItemsControl has a paneltemplate that can control ItemsControl's entry container.
DataTemplate can also function on a data type, except that it can be used on a control
We will have a module in the back of this place will be used, and now I simply say:
For example, you want to make a datatemplate, through this designation ControlTemplate, then you can follow this way, the specific later project will have a case
<datatemplate datatype= "{x:type your ViewModel type}" >
<contentcontrol template= "{StaticResource you define ControlTemplate}"/>
</DataTemplate>
Starting from 0 WPF MVVM Enterprise-level framework implementation and description----third speaking WPF DataTemplate