Check if the binding property exists or not.

I have a situation where there is a common control that uses several places in the application.

Now I have a data trigger for the say A. property. Ie

Binding DataTrigger = {Binding A} .......

Now it is possible that property A does not exist in the view model, in this case I need to add another trigger based on property B (which exists in this ViewModel).

Sort of:

Multidatatrigger

DataTrigger Binding A - doesn't exist DataTrigger Binding B 

Do something.....

Can someone tell me how I should approach this. As if I am trying to do as such, then a bind exception will be thrown because A does not exist in the current view model. Or any other approach will work here ... Thanks

+4
source share
1 answer

You can use PriorityBinding .

 <DataTrigger Value="XXX"> <DataTrigger.Binding> <PriorityBinding> <Binding Path="A"/> <Binding Path="B"/> </PriorityBinding> </DataTrigger.Binding> <Setter ... </DataTrigger> 
+8
source

All Articles