如何在鼠标悬停期间更改ComboBox的背景属性 [英] How to change ComboBox's Background Property during Mouse Hover

查看:274
本文介绍了如何在鼠标悬停期间更改ComboBox的背景属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含ComboBox的圆形边框,如下所示:

I have a Rounded Border containing a ComboBox as follow:

只要我的鼠标悬停在ComboBox上,我就得到了

As soon as my mouse hover on the ComboBox, I get this

我想摆脱按钮样的背景。我尝试在 MouseEnter MouseLeave MouseUp ,鼠标设置背景为白色或空白,但仍然无法摆脱ComboBox上的默认按钮背景。

I want to get rid of the button-like background. I tried setting background to white or null in MouseEnter, MouseLeave, MouseUp... everything with Mouse but still I can't get rid of the default button background on the ComboBox. Does anyone has a clue?

以下代码:

/* XAML */
<Border CornerRadius="11" BorderThickness="1" Height="24" Width="70" 
    Grid.Column="1" Margin="5,5,5,5" VerticalAlignment="Center" 
    HorizontalAlignment="Left" Background="White">
    <ComboBox x:Name="comboBox1" BorderBrush="{x:Null}" 
          Background="{x:Null}" Width="70" MouseMove="MouseHover"
          MouseEnter="MouseHover"
    </ComboBox>
    </Border>

/* C# code */
private void MouseHover(object sender, RoutedEventArgs e)
{
    comboBox1.Background = null;
}


推荐答案

a href =http://msdn.microsoft.com/en-us/library/ms752094%28v=VS.85%29.aspx =nofollow>默认控制模板。请检查下面的链接

You have to modify the default controlTemplate of the Combobox for this.Check the link below

http://social.msdn.microsoft.com/Forums/en/wpf/thread/a18891e9-8879-4819-9679-247341782f60

这篇关于如何在鼠标悬停期间更改ComboBox的背景属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆