更改项目中所有组合框的selecteditem颜色 [英] Change selecteditem color of all combo boxes in a project
问题描述
我想更改项目中所有组合框的selecteditem颜色。 我知道我需要在app.xaml中设置样式我不知道该怎么做。
我想更改项目中所有组合框的selecteditem颜色。 我知道我需要在app.xaml中设置一个样式我不知道该怎么做。
你好wegoodwin,
以下示例供您参考。
App.xaml:
< Application.Resources>
< Style x:Key =" ComboBoxItemStyle" TargetType =" {x:Type ComboBoxItem}">
< Setter Property =" Template">
< Setter.Value>
< ControlTemplate TargetType =" {x:Type ComboBoxItem}">
< Border x:Name =" myBorder">
< ContentPresenter />
< / Border>
< ControlTemplate.Triggers>
< Trigger Property =" IsMouseOver"值= QUOT;真">
< Setter Property =" Background"的TargetName = QUOT; myBorder"值= QUOT;黄色" />
< / Trigger>
< /ControlTemplate.Triggers>
< / ControlTemplate>
< /Setter.Value>
< / Setter>
< / Style>
< /Application.Resources>
您的页面:
< ComboBox IsEditable =" True" ItemContainerStyle =" {DynamicResource ComboBoxItemStyle} " IsTextSearchEnabled = QUOT假QUOT; >
< ComboBoxItem Content =" ComboBox Item#1" />
< ComboBoxItem Content =" ComboBox Item#2" />
< ComboBoxItem Content =" ComboBox Item#3" />
< / ComboBox>
如何在弹出的
组合框中更改高亮颜色
$
如果我有任何误解,您可以为其他任何人提供所有必要的代码段,以便能够从头开始重现您的问题以及有关结果的详细说明,包括任何异常消息。
感谢您的理解。
最好的问候,
Yong Lu
I wanted to change the selecteditem color of all the combo boxes in my project. I know I need to set a style in app.xaml I am just not sure how to do that.
I wanted to change the selecteditem color of all the combo boxes in my project. I know I need to set a style in app.xaml I am just not sure how to do that.
Hi wegoodwin,
The following sample for your reference.
App.xaml:
<Application.Resources> <Style x:Key="ComboBoxItemStyle" TargetType="{x:Type ComboBoxItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ComboBoxItem}"> <Border x:Name="myBorder"> <ContentPresenter /> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" TargetName="myBorder" Value="Yellow" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </Application.Resources>Your Page:
<ComboBox IsEditable="True" ItemContainerStyle="{DynamicResource ComboBoxItemStyle}" IsTextSearchEnabled="False" > <ComboBoxItem Content="ComboBox Item #1"/> <ComboBoxItem Content="ComboBox Item #2"/> <ComboBoxItem Content="ComboBox Item #3"/> </ComboBox>
How to change highlight color in popup of combobox
If I have any misunderstanding, you can include all necessary code snippets for anyone else to be able to reproduce your issue from scratch along with a detailed description about the results including any exception messages.
Thank you for your understanding.
Best Regards,
Yong Lu
这篇关于更改项目中所有组合框的selecteditem颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!