MouseOver高亮显示样式一秒钟后恢复为默认样式(由Aero导致?) [英] MouseOver highlighting style returning to default after a second (Caused by Aero?)

查看:490
本文介绍了MouseOver高亮显示样式一秒钟后恢复为默认样式(由Aero导致?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会尝试风格我的ComboBoxes匹配其余的UI,但我有IsMouseOver突出显示的问题。它突出显示与我指定的颜色一秒,然后退回到默认颜色,一种凉爽的效果,但不是我要去的。这是我的风格:

I'd trying to style my ComboBoxes to match the rest of the UI but I'm having problems with the IsMouseOver highlighting. It highlights with the color I specify for a second and then fades back to the default color, kind of a cool effect but not what I'm going for. Here is my style:

<Style TargetType="ComboBox">
    <Style.Triggers>
        <Trigger Property="ComboBox.IsMouseOver" Value="True">
            <Setter Property = "Background" Value="Red"/>
        </Trigger>
    </Style.Triggers>
</Style>

我能做些什么使背景颜色保留?

What can I do to make the background color stay?

推荐答案

问题的确是由于ComboBox的默认模板。如果您使用 Reflector 打开PresentationFramework.Aero程序集,您可以查看ButtonChrome类。有一个名为OnRenderMouseOverChanged的方法隐藏了红色背景。

The problem is indeed due to the default template for the ComboBox. If you use Reflector to open the PresentationFramework.Aero assembly you can take a look at the ButtonChrome class. There is a method called OnRenderMouseOverChanged that is hiding the Red background.

虽然它是一个很大的工作,至少对于ComboBox,你可能想覆盖默认ComboBox的模板。您可以使用显示我的意见,了解ComboBox temlpate是什么样子的基本概念模板混合

Even though it is a lot of work, for ComboBox at least, you probably will want to override the default template for the ComboBox. You can get the basic idea of what the ComboBox temlpate is like by using Show Me The Template or Blend.

您可以使用相同的样式来覆盖模板。

You can use your same style to override the template.

<Style TargetType="{x:Type ComboBox}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ComboBox}">
                <!-- Template Here -->
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

这篇关于MouseOver高亮显示样式一秒钟后恢复为默认样式(由Aero导致?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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