【发布时间】:2015-04-14 13:05:54
【问题描述】:
<ComboBox
Foreground="Black"
BorderBrush="Black"
HorizontalAlignment="Left" Margin="108,280,0,0" VerticalAlignment="Top" Width="200" Style="{StaticResource ComboBoxStyl}"><ComboBoxItem Content="One" IsSelected="True" Style="{StaticResource ComboBoxItemStyle1}"/>
<ComboBoxItem Content="Two" Style="{StaticResource ComboBoxItemStyle1}"/>
<ComboBoxItem Content="Three" Style="{StaticResource ComboBoxItemStyle1}"/>
<ComboBoxItem Content="Four" Style="{StaticResource ComboBoxItemStyle1}"/>
<ComboBoxItem Content="Five" Style="{StaticResource ComboBoxItemStyle1}"/>
</ComboBox>
这里我提到了每个 ComboBoxItem 的样式表。我只想引用一次样式表(相对于 ComboBoxItem)。因此,当向其中添加动态数据项时,样式将自动应用。
【问题讨论】:
-
要将单一样式应用于所有项目,您可以使用
ItemContainerStyle像这样<ComboBox ItemContainerStyle="{StaticResource ComboBoxItemStyle1}">
标签: xaml windows-phone-8 windows-phone windows-phone-8.1 windows-phone-8-emulator