You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes we will need to use triggers to make some "not equals to value" scenarios (most common case: value is not null), but for such scenarios it is often necessary to add additional code in the code behind to achieve (such as add a "not" property in entity, or implement IValueConverter, even invert the default value).
But It seems that just adding a "Negate" property to the Trigger and Condition can makes everything easier.
Is it possible?? Or why not?
The text was updated successfully, but these errors were encountered:
Back when I used WPF at work, I would regularly curse the fact that Trigger/DataTrigger don't support binary comparisons other than positive equality and that you're forced to contort the perspective of your trigger conditions and/or use converters. I tried many times to make a derived trigger type that would support other comparisons, but I always arrived at the conclusion that it was too hard without modifying the framework.
I speculate that a pretty quick win would be adding an enum of binary comparisons (Equals, NotEquals, GreaterThan, etc.), adding a property of that type to Trigger/DataTrigger whose default value is Equals, and then updating the evaluation function to act on the result of (value as IComparable)?.CompareTo(comparand). This would make triggers SO much easier to use and remove a bunch of uses of InvertedBooleanConverter or whatever.
However, WPF is in maintenance mode and Microsoft has given no indication that that's changing. The commit list is almost all automated stuff. If it's not related to a vulnerability, it's probably not going in. An example of why this is true is this; it's a totally trivial change that would make life easier for developers and would take longer to document than it would to implement, but here we are over 3 years later.
Sometimes we will need to use triggers to make some "not equals to value" scenarios (most common case: value is not null), but for such scenarios it is often necessary to add additional code in the code behind to achieve (such as add a "not" property in entity, or implement IValueConverter, even invert the default value).
But It seems that just adding a "Negate" property to the
Trigger
andCondition
can makes everything easier.Is it possible?? Or why not?
The text was updated successfully, but these errors were encountered: