Using binding for the Value property of DataTrigger condition

后端 未结 4 578
无人及你
无人及你 2020-11-29 07:55

I\'m working on a WPF application and struggling with a data trigger. I\'d like to bind the value of the trigger condition to some object I have:



        
4条回答
  •  清酒与你
    2020-11-29 08:31

    No, it is not possible. As the error message says, only dependency properties can be targets of WPF bindings, and DataTrigger.Value is not a dependency property. So you will need to assign an actual value.

    The workaround is to use a MultiBinding whose child Bindings are the two bindings you want to compare, with an IMultiValueConverter which returns true if the two inputs are equal and false if they are unequal. The DataTrigger can then use that MultiBinding, and a Value of True.

提交回复
热议问题