Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add new "Negate" property in "Trigger" and "Condition" on use Trigger scene. #6189

Open
Flithor opened this issue Mar 1, 2022 · 1 comment

Comments

@Flithor
Copy link

Flithor commented Mar 1, 2022

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?

@bhood-zorus
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants