使用Binding在对象类型的基础上设置一个按钮 [英] desable a button on the basis of object type using Binding

查看:79
本文介绍了使用Binding在对象类型的基础上设置一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

我有以下按钮

dear all,
I have following button

<Button x:Name="btnNew" Content="*"  Grid.Column="0" Click="btnNew_Click" />



和运行时命名为currentObject的对象
其类型的基础我决定是否启用按钮。

我想要这个逻辑


and an object in runtime naming "currentObject"
the the bases of its type I am to decide wheather to enable the button or not.
I want this logic

if(currentObject is Inewable)
 btnNew.IsEnabled= true;
else
btnNew.IsEnabled= false;





我想用xaml而不是csharp代码通过Binding来做这个

你能帮忙怎么做。

问候

推荐答案

通过ValueConverter将按钮的IsEnabled属性绑定到您的对象。请参阅

http://www.wpftutorial.net/ValueConverters.html [ ^ ]



是清楚还是需要更多信息?
Bind IsEnabled property of button to your object over a ValueConverter. See
http://www.wpftutorial.net/ValueConverters.html[^]

Is it clear or do you need more information?


这篇关于使用Binding在对象类型的基础上设置一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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