[Multi]DataTrigger "OR" statement?
Asked Answered
I

2

12

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

Indomitability answered 25/10, 2011 at 12:5 Comment(0)
C
6

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.

Chassidychassin answered 25/10, 2011 at 12:16 Comment(0)
F
4

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!

Finfoot answered 25/10, 2011 at 16:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.