tags:

views:

402

answers:

1

Hi ! How to trigger an action in WPF when the Property is not null? This is a working solution when is null:

<Style.Triggers>
    <DataTrigger Binding="{Binding}" Value="{x:Null}">

      <Setter Property="Background" Value="Yellow" />

    </DataTrigger>
</Style.Triggers>

I know that you cant "turn around" the condition and do what you need, but want to know

+1  A: 

Unfortunately, you can't. But actually it's not necessary : you just need to specify the background for when the value is not null in the style setters, not in the trigger :

<Style.Setters>
    <!-- Background when value is not null -->
    <Setter Property="Background" Value="Blue" />
</Style.Setters>
<Style.Triggers>
    <DataTrigger Binding="{Binding}" Value="{x:Null}">

      <Setter Property="Background" Value="Yellow" />

    </DataTrigger>
</Style.Triggers>
Thomas Levesque
"Binding" is not a property...
Thomas Levesque