检查绑定属性是否存在
我遇到的情况是,有一个通用控件在应用程序中的几个地方使用。
现在,我在属性 A 上有一个数据触发器。即
DataTrigger Binding={Binding A} .......
现在视图模型中可能不存在属性 A,在这种情况下我需要基于属性 B 添加另一个触发器(该触发器存在于该 ViewModel 中)。
像:
Multidatatrigger
DataTrigger Binding A - doesn't exist
DataTrigger Binding B
做点什么......
有人可以建议我应该如何处理这个问题。 。好像我尝试这样做,那么将抛出绑定异常,因为当前视图模型中不存在 A 。或者任何其他方法都可以在这里工作...... 谢谢
I've a situation in which there is a common control which is used couple of places in application.
Now in this i've a data trigger on a property say A. i.e.
DataTrigger Binding={Binding A} .......
Now it may be possible that property A doesn't exist in view model, in that case i need to add another trigger based on property B (which exist in that ViewModel).
Something like:
Multidatatrigger
DataTrigger Binding A - doesn't exist
DataTrigger Binding B
Do something.....
Can someone suggest me how i should approach for this. . As if i try to do as such then binding exception will be thrown because A doesn't exist in current View Model. Or any other approach would work here...
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 优先级绑定。
You can make use of PriorityBinding.