Alberto Bortolato
Alberto Bortolato

Reputation: 13

Text.IsEmpty Opposite

i have this CheckBox

<CheckBox VerticalAlignment="Center" Name="CheckItem"
          IsChecked="{Binding ElementName=Faccette, Path=Text.isEmpty, Mode=OneWay}"
                     />

Faccette is a TextBlock, i need the opposite of the Text.isEmpty. Is it possible without a Converter?

Upvotes: 1

Views: 362

Answers (1)

Clemens
Clemens

Reputation: 128157

You may use a Style with DataTriggers:

<CheckBox>
    <CheckBox.Style>
        <Style TargetType="CheckBox">
            <Setter Property="IsChecked" Value="True"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=Faccette, Path=Text}" Value="">
                    <Setter Property="IsChecked" Value="False"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding ElementName=Faccette, Path=Text}" Value="{x:Null}">
                    <Setter Property="IsChecked" Value="False"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </CheckBox.Style>
</CheckBox>

Upvotes: 2

Related Questions