xamarin-forms-to-net-maui/Triggers
Javier Suárez 37c918debd Created Triggers README 2021-07-04 18:49:55 +02:00
..
.NET MAUI Add Triggers samples 2021-07-04 12:00:29 +02:00
Xamarin.Forms Add Triggers samples 2021-07-04 12:00:29 +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>