如何在Windows 8商店应用中更改组合框箭头的颜色

3

我在一个Windows Store应用项目中有一个下拉框

<ComboBox  Grid.Row="2" x:Name="ContactoSelect" Width="200" Height="50" Margin="114,10,27,510" SelectedIndex="0" Background="White" SelectionChanged="ContactoSelect_SelectionChanged">
    <x:String>Item 1</x:String>
    <x:String>Item 2</x:String>
    <x:String>Item 3</x:String>
</ComboBox>

我想要改变默认为黑色的箭头的颜色,我该怎么做?

2个回答

5

从设计视图中右键单击控件

选择"编辑样式">"编辑副本"选项

将在xaml中的Page.Resources中为该控件创建一个样式,样式名称为ComboBoxStyle1(根据您的x:name而异)

您会发现

<TextBlock x:Name="DropDownGlyph" Grid.Column="1" Foreground="{StaticResource ComboBoxArrowForegroundThemeBrush}" FontWeight="Bold" FontSize="{StaticResource ComboBoxArrowThemeFontSize}" FontFamily="{StaticResource SymbolThemeFontFamily}" HorizontalAlignment="Right" IsHitTestVisible="False" Margin="0,0,6,4" Text="&#xE011;" VerticalAlignment="Center"/>

将前景色更改为所需的颜色。 例如:Foreground="Red"或任何其他资源绑定。

您可以在App.xaml中全局定义样式,以便在其他地方使用,如下所示:

    <ComboBox HorizontalAlignment="Left" Margin="187,130,0,0" VerticalAlignment="Top" Width="120" Style="{StaticResource ComboBoxStyle1}"/>

在 Visual Studio 2013 Update 1 中,它是“编辑模板”而不是“编辑样式”。 - Trisped

0
如果您想要更改项目中所有ComboBox对象的箭头,您可以将以下行添加到您的App.xaml文件,并将“#FF000000”更改为您想要的颜色。
<SolidColorBrush x:Key="ComboBoxArrowForegroundThemeBrush" Color="#FF000000" />

您也可以通过在资源中指定来在页面/控件级别上执行此操作。

从ComboBox样式和模板下的暗主题画笔


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接