Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check whether the binding property exists or not

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

like image 618
Rohit Avatar asked Jul 12 '11 14:07

Rohit


1 Answers

You can make use of PriorityBinding.

<DataTrigger Value="XXX">
  <DataTrigger.Binding>
     <PriorityBinding>
        <Binding Path="A"/>
        <Binding Path="B"/>
     </PriorityBinding>
  </DataTrigger.Binding>
  <Setter ...
</DataTrigger>
like image 55
anivas Avatar answered Oct 08 '22 01:10

anivas