---
title: "Property Triggers in WPF"  
description: "These are the most common and basic types of triggers within the WPF programmatic model. They are basically  XAML condition statements that check the"  
author: "Uttam Misra"  
published: 2011-05-12  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/168/property-triggers-in-wpf  
category: "wpf"  
tags: ["wpf"]  
reading_time: 2 minutes  

---

# Property Triggers in WPF

These are the most common and basic types of [triggers](https://www.mindstick.com/articles/337000/what-are-sql-triggers-and-ways-of-using-them-effectively) within the WPF programmatic model. They are basically XAML [condition](https://www.mindstick.com/forum/12711/select-query-with-and-condition) statements that check the state of a [property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) to [determine whether](https://www.mindstick.com/forum/161622/how-do-you-determine-whether-a-file-is-locked-or-in-use-by-another-process) to use a specific style/setter value within the style of the element.

##### The following are the basic steps for creating a property trigger:

1. Create a top-level <Style> XML element in your XAML page and set the TargetType of the

<Style> XML element to {x:Type Button}:

<Style TargetType=”{x:Type Button}”>

2. Within the <Style> entries, define the <Style.[Trigger](https://www.mindstick.com/blog/167/triggers-in-wpf)> element:

<Style.Triggers>

3. Within the <Style.Triggers> XML element, create a <Trigger> XML element with the property to check and the value to compare it to set as [attributes](https://www.mindstick.com/articles/13105/2-attributes-that-make-your-odoo-ecommerce-theme-productive-and-engaging) for this class:

<Trigger Property=”IsMouseOver” Value=”False”>

</Trigger>

4. Enter the <Setter> XML element to designate the actual property value of the [Button control](https://www.mindstick.com/articles/290/button-control-in-vb-dot-net)(s)

that will need to be rendered. In this case, the [developer](https://www.mindstick.com/articles/157260/variation-between-web-designer-and-web-developer) can set the property to be modified in the trigger’s condition routine.

<Setter Property=”[Background](https://www.mindstick.com/articles/65/how-to-change-background-color-of-tab-control-in-c-sharp)” Value=”Red” />

5. Add a button to the XAML page, with no special [settings](https://www.mindstick.com/blog/63563/steps-to-change-the-wireless-settings-using-linksys-cloud-account) needed:

<Button VerticalAlignment=”Left”

HorizontalAlignment=”Stretch”

Height=”66”

Name=”btnOne”>Button

</Button>

\

##### The final syntax should resemble the following:

```
<Window x:Class=”PropertyTrigger.Window1”xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”Title=”PropertyTrigger”><Window.Resources><Style TargetType=”{x:Type Button}”><Style.Triggers><Trigger Property=”IsMouseOver” Value=”False”><Setter Property=”Background” Value=”Red” /></Trigger></Style.Triggers></Style></Window.Resources><Grid><Button VerticalAlignment=”Left”HorizontalAlignment=”Stretch”Height=”66”Name=”btnOne”>Button</Button></Grid></Window>
```

As displayed, the setter property would apply only when the trigger is evaluated to be a False condition.

If the trigger is evaluated to a True value, it will not fire.

---

Original Source: https://www.mindstick.com/blog/168/property-triggers-in-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
