当鼠标悬停在我的ComboBox上时,我的ComboBox的背景会产生一对可怕的蓝色/浅蓝色.我在这里尝试了解决方案:ComboBox鼠标颜色,WPF Combobox鼠标结束,如何在鼠标悬停上设置ComboBox背景样式?或者WPF组合框默认悬停颜色在togglebutton上,但它不会改变任何东西,我仍然在悬停时获得默认颜色.
有什么建议 ?
感谢所有人,Demasiado.
这是XAML代码:
<Window x:Class="Homepage.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<Window.Resources>
<Storyboard x:Key="TileZoomIn">
<ThicknessAnimation Storyboard.TargetProperty="Margin" From="10" To="1" Duration="0:0:0.1"/>
</Storyboard>
<Storyboard x:Key="TileZoomOut">
<ThicknessAnimation Storyboard.TargetProperty="Margin" From="1" To="10" Duration="0:0:0.1"/>
</Storyboard>
<DropShadowEffect x:Key="DropShadowEffect" BlurRadius="20" Opacity="1" ShadowDepth="0" Color="White"/>
</Window.Resources>
<Grid ShowGridLines="True">
<ComboBox Name="comboBoxTRIG" FontSize="40" Width="210" Height="98" HorizontalAlignment="Left" HorizontalContentAlignment="Center" Margin="40,-180,0,256" Background="Transparent" BorderBrush="Transparent" Foreground="White" BorderThickness="0">
<ComboBox Margin="25" Width="130" Height="50">
<ComboBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Green"/>
</ComboBox.Resources>
</ComboBox>
</ComboBox>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
SystemColors.HighlightBrushKey您可以在范围内覆盖ComboBox:
<ComboBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Green"/>
</ComboBox.Resources>
Run Code Online (Sandbox Code Playgroud)

整个 XAML 可以是这样的:
<Grid>
<ComboBox Margin="25" Width="130" Height="50">
<ComboBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Green"/>
</ComboBox.Resources>
<ComboBox.ItemsSource>
<Binding Path="Collection" Source="{StaticResource viewmodel}"/>
</ComboBox.ItemsSource>
</ComboBox>
</Grid>
Run Code Online (Sandbox Code Playgroud)
您的评论的后续行动:
忽略viewmodel,我的ItemSource你应该使用你自己的,这只是为了演示。
至于你的评论
我无法完成任何工作
我建议您创建一个新项目并仅测试此 XAML(当然使用您的 ItemSource),看看是否可以获得您想要的结果。当你明白了之后,你就可以转移到你的真实项目中,看看样式在哪里发生了变化,问题出在哪里。
编辑#2:
为了改变颜色,ToggleButton我认为最好覆盖整个ComboBox样式。

我用过
<ControlTemplate x:Key="ComboBoxToggleButton"
TargetType="{x:Type ToggleButton}">
Run Code Online (Sandbox Code Playgroud)
其余的代码和样式取自这里。
我建议您也阅读此内容。
| 归档时间: |
|
| 查看次数: |
3580 次 |
| 最近记录: |