I have a problem with WPF triggers. In my application i used a multitrigger but would like to achieve that changes made when a trigger’s conditions become true to persist and NOT to be invalidated when the trigger’s conditions become false AGAIN.
Is it possible to realize what I want ?
Thanks in advance.
Triggers don’t have any memory: As soon as the trigger becomes inapplicable the trigger’s setters are unapplied. You want a condition that “locks on” once it has been set. This can be done with a very simple and generic piece of code.
First you need an attached property that you can “lock on”. Here’s a simple class with a “IsLocked” attached property that becomes true whenever the “DoLock” property is set and stays that way from then on:
Now you can emulate a locking trigger using two separate triggers:
Note that the first trigger in this example can be a Trigger, DataTrigger, MultiTrigger or MultiDataTrigger – whatever you need to express your triggering condition.