xamarin-forms-to-net-maui/Triggers
Javier Suárez Ruiz 59cc0b9caa Updated .NET MAUI Triggers sample 2022-03-27 17:56:51 +02:00
..
.NET MAUI Updated .NET MAUI Triggers sample 2022-03-27 17:56:51 +02:00
Xamarin.Forms Updated Xamarin.Forms Triggers sample versions 2022-03-27 12:22:25 +02:00
README-es.md Added Spanish Triggers README 2021-07-19 11:16:16 +02:00
README.md Created Triggers README 2021-07-04 18:49:55 +02:00

README.md

Port Xamarin.Forms Triggers to .NET MAUI

Triggers allow you to express actions declaratively in XAML that change the appearance of controls based on events or property changes. In addition, state triggers, which are a specialized group of triggers, define when a VisualState should be applied.

As a general rule, all XAML-related concepts in Xamarin.Forms will work without require changes in .NET MAUI.

Xamarin.Forms

<Entry 
    x:Name="Entry"
    Text=""
    Placeholder="Required field" />
<!-- Referenced below in DataTrigger-->
<Button 
    x:Name="Button"
    Text="Save"
    FontSize="Large"
    HorizontalOptions="Center">
    <Button.Triggers>
        <DataTrigger
            TargetType="Button"
            Binding="{Binding Source={x:Reference Entry},
                            Path=Text.Length}"
            Value="0">
            <Setter Property="IsEnabled" Value="False" />
        </DataTrigger>
    </Button.Triggers>
</Button>

.NET MAUI

<Entry 
    x:Name="Entry"
    Text=""
    Placeholder="Required field" />
<!-- Referenced below in DataTrigger-->
<Button 
    x:Name="Button"
    Text="Save"
    FontSize="Large"
    HorizontalOptions="Center">
    <Button.Triggers>
        <DataTrigger
            TargetType="Button"
            Binding="{Binding Source={x:Reference Entry},
                            Path=Text.Length}"
            Value="0">
            <Setter Property="IsEnabled" Value="False" />
        </DataTrigger>
    </Button.Triggers>
</Button>