Data Triggers

Learn how to use data triggers in .NET MAUI.

We'll cover the following...

Data triggers perform an action when a specific data value changes in a specific way. In the example below, we'll look at a trigger that disables a submit button when the text is deleted from a text box on the page. We'll use the following project setup for demonstration.

<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:DataTriggerDemo"
             x:Class="DataTriggerDemo.App">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources/Styles/Colors.xaml" />
                <ResourceDictionary Source="Resources/Styles/Styles.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
.NET MAUI project example with data triggers demonstration

Adding data trigger to XAML markup

In the ...