【发布时间】:2017-07-22 16:47:07
【问题描述】:
我不确定 wpf 控件的分层模板。例如,对于组合框。
<ComboBox ItemsSource="{Binding .}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Border HorizontalAlignment="Stretch">
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ComboBoxItem}, Path=DataContext.IsSelected}" Value="True">
<Setter Property="Background" Value="LightGreen"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<StackPanel HorizontalAlignment="Stretch">
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding Email}">
</TextBlock>
</StackPanel>
</Border>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
它可能有类似的控制模板,但我不知道。
combox 有一个模板子 ItemTemplate 和一个孙子 DateTemplate。那么对于一个控件来说,有多少个模板子孙呢?我们可以在图表中列举它们以及它们之间的关系吗?
【问题讨论】:
标签: wpf xaml templates controls