Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Why triggers don't work on invisible controls?

$
0
0

I don't know why the DataTrigger only works when the control is visible, What I'm doing something wrong?

Trigger on Visibility True

<StackLayout
            x:Name="StackLayoutForm"
            IsVisible="{Binding IsFormVisible}">
            <Label Text="Name" />
            <Entry
                x:Name="EntryName"
                Text="Foo">
                <Entry.Triggers>
                    <DataTrigger
                        Binding="{Binding IsFormVisible}"
                        TargetType="Entry"
                        Value="True">
                        <Setter Property="Text" Value="" />
                    </DataTrigger>
                </Entry.Triggers>
            </Entry>
</StackLayout>

Trigger on Visibility False

<StackLayout
            x:Name="StackLayoutForm"
            IsVisible="{Binding IsFormVisible}">
            <Label Text="Name" />
            <Entry
                x:Name="EntryName"
                Text="Foo">
                <Entry.Triggers>
                    <DataTrigger
                        Binding="{Binding IsFormVisible}"
                        TargetType="Entry"
                        Value="False">
                        <Setter Property="Text" Value="" />
                    </DataTrigger>
                </Entry.Triggers>
            </Entry>
</StackLayout>

Output

IsFormVisible == true
EntryName.Text == ""

IsFormVisible == false
EntryName.Text == "Foo"

I hope someone can help me.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>