如何使用触发器处理控件的可见性属性 [英] How to handle visibility property of control with triggers

查看:90
本文介绍了如何使用触发器处理控件的可见性属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是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:
  1. 将鼠标移到按钮上;
  2. IsMouseOver true ,所以你的触发器会隐藏按钮;
  3. 按钮被隐藏,所以鼠标不能超过按钮。触发器再次显示该按钮;
  4. IsMouseOver true ,因此您的触发器会隐藏按钮;
  5. ...
  1. You move the mouse over the button;
  2. IsMouseOver is true, so your trigger hides the button;
  3. The button is hidden, so the mouse cannot be over the button. The trigger shows the button again;
  4. IsMouseOver is true, so your trigger hides the button;
  5. ...



您可以尝试将按钮的不透明度设置为 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屋!

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