Search code examples
wpfdatatrigger

[Multi]DataTrigger "OR" statement?


I want my image Visibility property set to Hidden when my bound table field

Weblink = NULL **OR** Weblink = ""

With MultiDataTrigger you can test several conditions in the following logic:

"IF FieldA = 1 **AND** FieldB = 2 THEN"

But what I need is

"IF FieldA = 1 **OR** FieldA = 2 THEN"

Here is part of my xaml whitch is only working when Weblink = ""; when Weblink = NULL my image stays visible

<Image.Style>
    <Style TargetType="{x:Type Image}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Weblink}" Value="Null">
                <Setter  Property="Visibility" Value="Hidden" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Weblink}" Value="">
                <Setter  Property="Visibility" Value="Hidden" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
</Image.Style>  

Thanks in advance ! Spoelle


Solution

  • What you wrote is equal to Weblink == "Null" but you need Weblink == null.

    Try Value="{x:Null}" in the DataTrigger when the the Weblink property returns with null.