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.
现在我已经在一个属性上的数据触发器说A.即
DataTrigger Binding={Binding A} .......
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).
现在,视图模型中可能不存在属性A,在这种情况下,我需要添加基于属性B的另一个触发器(存在于该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
有人可以建议我如何处理这个问题。 。好像我试图这样做,然后将抛出绑定异常,因为A在当前视图模型中不存在。或者任何其他方法都可以在这里工作......谢谢
1 个解决方案
#1
8
You can make use of PriorityBinding.
您可以使用PriorityBinding。
<DataTrigger Value="XXX">
<DataTrigger.Binding>
<PriorityBinding>
<Binding Path="A"/>
<Binding Path="B"/>
</PriorityBinding>
</DataTrigger.Binding>
<Setter ...
</DataTrigger>
#1
8
You can make use of PriorityBinding.
您可以使用PriorityBinding。
<DataTrigger Value="XXX">
<DataTrigger.Binding>
<PriorityBinding>
<Binding Path="A"/>
<Binding Path="B"/>
</PriorityBinding>
</DataTrigger.Binding>
<Setter ...
</DataTrigger>