积极答复者
如何禁止button的pointerover state?

问题
-
button的四个状态 Normal state/PointerOver state/Pressed state/Disabled state有不同的样式效果,我现在想做的是禁止掉pointerover这个样式,即鼠标指针划过button时不会引发背景色的改变,不知该如何操作?
自己试着在App.xaml里加了一句<SolidColorBrush x:Key="ButtonPointerOverBackgroundThemeBrush" Color="#FF000000" />
但是这个透明的效果也不理想,因为我的button本身有背景色,我就是想让鼠标指针进入button时背景色不会改变
新手一名,希望大家多多赐教!
答案
-
这样来做吧,跟着我的截图来试试看:
1,在VS界面的XAML design环境下对Button右键,选择修改模板
之后你会看到XAML中多了很多代码,在这些代码中找到PointerOver这个Visual State里面的内容按照你需要的进行修改,我这里直接注释掉了。
这样你应该能看到你的Button在运行时候,鼠标滑过Button不会有背景色的变化问题啦。
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已标记为答案 Frank7777 2014年8月1日 7:11
全部回复
-
你好,
你可以尝试修改一下: Button styles and templates
在PointOver那一段里面,把所有的动画和样式全部屏蔽掉。
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已建议为答案 shao.mengModerator 2014年8月1日 6:31
-
这样来做吧,跟着我的截图来试试看:
1,在VS界面的XAML design环境下对Button右键,选择修改模板
之后你会看到XAML中多了很多代码,在这些代码中找到PointerOver这个Visual State里面的内容按照你需要的进行修改,我这里直接注释掉了。
这样你应该能看到你的Button在运行时候,鼠标滑过Button不会有背景色的变化问题啦。
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已标记为答案 Frank7777 2014年8月1日 7:11