Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[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

like image 262
Spoelle Avatar asked Oct 25 '11 12:10

Spoelle


2 Answers

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.

like image 92
Miklós Balogh Avatar answered Sep 28 '22 02:09

Miklós Balogh


I would suggest using the x:Null markup extension, and for sake of clarity explicitly specify the empty string by using the x:Static markup extension:

<DataTrigger Binding="{Binding Weblink}" Value="{x:Null}">
    <Setter  Property="Visibility" Value="Hidden" />
</DataTrigger>
<DataTrigger Binding="{Binding Weblink}" Value="{x:Static System:String.Empty}" >
    <Setter  Property="Visibility" Value="Hidden" />
</DataTrigger>

Hope this helps!

like image 37
FunnyItWorkedLastTime Avatar answered Sep 28 '22 02:09

FunnyItWorkedLastTime