删除文本框上的默认鼠标悬停/焦点效果 [英] Remove default mouseover/focus effect on textboxes
问题描述
我在Expression Blend中创建了一种自定义TextBox
.我将背景和边框的填充更改为渐变,并添加了阴影效果.
I have created a kind of custom TextBox
in Expression Blend. I have changed the fill of the background and border to a gradient, and added in a Shadow Effect.
我注意到,当我将鼠标悬停或聚焦在TextBox
上时,WPF的某些默认行为/(样式?)会接管并且边框也会更改.
I've noticed that when I mouseover or focus my TextBox
, some default behavior/(style?) of WPF takes over and my border is changed.
我想知道是否有什么方法可以阻止或阻止WPF在我将鼠标移至其上时更改我的TextBox
es样式.这可能吗?
I was wondering if there was anyway to prevent or stop WPF from changing my TextBox
es style when I focus or mouseover it. Is this possible?
推荐答案
您是否自定义样式,将OverridesDefaultStyle
属性设置为true
?我相信这可以防止从默认样式中绘制默认值.
Does you custom style set the OverridesDefaultStyle
property to true
? I believe this should prevent default values being drawn from the default style.
如果是这样,并且不起作用(或者您想使用自己的 own 边框),那么我能想到的是,对于在Style
中使用触发器更改适当的属性/ControlTemplate
:
If so, and this isn't working (or you want to use your own border), all I can think is that you will need to override the default styling mechanism for the event of the appropriate property changing using a Trigger in your Style
/ ControlTemplate
:
<Style x:Key="Triggers" TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property = "BorderBrush" Value="{Binding ToYourBorder}"/>
</Trigger>
</Style.Triggers>
</Style>
这篇关于删除文本框上的默认鼠标悬停/焦点效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!