What's the easiest way to do negation in triggers?
Asked Answered
H

2

5

I want to do something like

<DataTrigger Binding="{Binding Something}" ValueIsNot="{x:Null}">
Hema answered 10/10, 2009 at 12:19 Comment(0)
C
9

I think your best bet is to use a Converter. See this blog post for a sample for converting a result into a boolean.

<DataTrigger
    Binding="{Binding Path=x, Converter={StaticResource IsNotNullConverter}}"
    Value="true">
Carleton answered 10/10, 2009 at 13:8 Comment(0)
A
2

If you want to go with triggers, you could write your own or leverage existing ones. If you're doing MVVM, just bind the view to a property on your VM that does the logic for you.

Apfel answered 10/10, 2009 at 14:12 Comment(1)
Do you write that value converter library? Can I contribute some?Hema

© 2022 - 2024 — McMap. All rights reserved.