Property Triggers

Learn how to use data triggers in .NET MAUI.

Property triggers in .NET MAUI trigger some sort of action when a property on a specific page element is set to a specific value. There are multiple ways of defining property triggers. We'll look at them in the following project setup:

<?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:PropertyTriggersDemo"
             x:Class="PropertyTriggersDemo.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 property triggers demonstration

Adding property triggers

First, we'll look at how to add a property trigger to a specific element. We have an example of it on lines 37–47 on the MainPage.xaml file, where we're adding a property trigger to a specific Entry element.

Any trigger, including property triggers, is set inside a ...

Get hands-on with 1400+ tech skills courses.