WPF按钮IsPressed [英] WPF Button IsPressed

查看:615
本文介绍了WPF按钮IsPressed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用VS2010,我发现WPF中的Button有一个名为IsPressed的属性,它是一个只读属性(我的意思是我不能用true赋值)但是我还想手动按下Pressed状态按钮,你有任何想法吗?

Hi,
I am using VS2010 and I've found that The Button in WPF has a property named IsPressed and it is a readonly property ( I mean I can not assign it with true) but still I want to show my button in Pressed state manually, do you have any idea to do that?

推荐答案

你可以看一下这个 [ ^ ]文章。



这解释了如何简单地按下按钮状态的动画。
You can have a look at this [^] article.

This explains how to simply animations for the pressed state of a button.


Hi
IsPressed属性是只读,所以我们只能从代码中获取它的值。您可以改为使用ToggleButton,并将IsChecked属性设置为true。
Hi The IsPressed property is read only, so we can only get its value from code. You can use ToggleButton instead, and set IsChecked property to true.


VisualStateManager.GoToState(< your button =>,Pressed,true)
VisualStateManager.GoToState(<your button="">, "Pressed", true)


这篇关于WPF按钮IsPressed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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