WPFコントロールテンプレートとデータテンプレート
3482 ワード
:http://www.th7.cn/Program/WPF/2011/12/21/51676.shtml
ControlTemplate . TemplateBinding , {TemplateBinding Background}
DataTemplate Content. Binding , {Binding PersonName}
, ControlTemplate ContentPresenter, ContentPresenter ContentTemplate DataTemplate
Control
- Template (ControlTemplate )
- ContentPresenter
- ContentTemplate (DataTemplate )
ContentControl
- Template (ControlTemplate ) Control
- ContentTemplate (DataTemplate )
ItemsControl
- Template (ControlTemplate ) Control
- ItemsPanel (ItemsPanelTemplate )
- ItemTemplate (DateTemplate ) Item Template
<Style TargetType="Button">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Ellipse Fill="{TemplateBinding Background}"/>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>