Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-trigger-an-animation-when-a-property-value-changes.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

1.7 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Trigger an Animation When a Property Value Changes 03/30/2017
animation [WPF], starting when property values change
triggering animation [WPF]
Storyboards [WPF], starting when property values change
12399c21-0300-4f4f-9e3a-d92d9907e5f5

How to: Trigger an Animation When a Property Value Changes

This example shows how to use a xref:System.Windows.Trigger to start a xref:System.Windows.Media.Animation.Storyboard when a property value changes. You can use a xref:System.Windows.Trigger inside a xref:System.Windows.Style, xref:System.Windows.Controls.ControlTemplate, or xref:System.Windows.DataTemplate.

Example

The following example uses a xref:System.Windows.Trigger to animate the xref:System.Windows.UIElement.Opacity%2A of a xref:System.Windows.Controls.Button when its xref:System.Windows.UIElement.IsMouseOver%2A property becomes true.

[!code-xamlAnimatePropertyStoryboards#PropertyTriggerExample]

Animations applied by property xref:System.Windows.Trigger objects behave in a more complex fashion than xref:System.Windows.EventTrigger animations or animations started using xref:System.Windows.Media.Animation.Storyboard methods. They "handoff" with animations defined by other xref:System.Windows.Trigger objects, but compose with xref:System.Windows.EventTrigger and method-triggered animations.

See also