Reputation: 7237
We have Templates, Control Templates and Data Templates for WPF controls. I don't know if there exists any more types (please let me know if any). But, when to use what?
Upvotes: 1
Views: 1566
Reputation: 2944
As far as when to use what - you can usually tell by what you are overriding. It will be of either the type ControlTemplate or DataTemplate.
Upvotes: 0
Reputation: 20746
Look at the FrameworkTemplate
derived types:
ControlTemplate
- Specifies the visual structure and behavioral aspects of a Control
that can be shared across multiple instances of the control.;DataTemplate
- Describes the visual structure of a data object;ItemsPanelTemplate
- Specifies the panel that the ItemsPresenter
creates for the layout of the items of an ItemsControl
.P.S.: As you can see there is no just "Template" :)
Upvotes: 3
Reputation: 29120
<UserControl.Resources>
<HierarchicalDataTemplate DataType="{x:Type src:League}" ItemsSource="{Binding Path=Divisions}">
<TextBlock Text="{Binding Path=Name}"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type src:Division}" ItemsSource = "{Binding Path=Teams}">
<TextBlock Text="{Binding Path=Name}"/>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type src:Team}">
<TextBlock Text="{Binding Path=Name}"/>
</DataTemplate>
</UserControl.Resources>
Upvotes: 1