如何使用触发器处理控件的可见性属性 [英] How to handle visibility property of control with triggers
问题描述
我是WPF的新手,我创建了应用程序,我想在其中处理带触发器的Button的可见性属性。
我在我的内联样式Button中创建了触发器,当IsMouseOver属性时是的,我保持按钮隐藏的可见性。
但是当我运行应用程序并在按钮上运行我的光标时,它的可见性隐藏不会保持不变它每次我按下按钮时都会发出波动。
请帮助。
提前谢谢:)
I am new in WPF and I have created application in which i want to handle visibility property of Button with triggers.
I have created trigger inside my inline style of Button and when "IsMouseOver" property is true, I keep visibility of button hidden.
But when i run application and run my curser over button, its visibility "Hidden" doesn't stay constant it fluctuate every time i run my curser over button.
Please need help.
Thank you in advance :)
推荐答案
想想会发生什么:
Think about what happens:
- 将鼠标移到按钮上;
-
IsMouseOver
是true
,所以你的触发器会隐藏按钮; - 按钮被隐藏,所以鼠标不能超过按钮。触发器再次显示该按钮;
-
IsMouseOver
是true
,因此您的触发器会隐藏按钮; - ...
- You move the mouse over the button;
IsMouseOver
istrue
, so your trigger hides the button;- The button is hidden, so the mouse cannot be over the button. The trigger shows the button again;
IsMouseOver
istrue
, so your trigger hides the button;- ...
您可以尝试将按钮的不透明度
设置为 0
而不是隐藏它。
然而,这听起来像是一个非常烦人且无法使用的UI设计。
You could try setting the button's Opacity
to 0
instead of hiding it.
However, this sounds like an extremely annoying and unusable UI design.
这篇关于如何使用触发器处理控件的可见性属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!