Represents a trigger that applies a set of actions in response to an event.
Assembly: PresentationFramework (in PresentationFramework.dll)
Gets the collection of actions to apply when the event occurs.
Gets a value that indicates whether this instance is currently sealed (read-only).(Inherited from DependencyObject.)
Gets or sets the RoutedEvent that will activate this trigger.
Gets or sets the name of the object with the event that activates this trigger. This is only used by element triggers or template triggers.
Adds the specified object to the Actions collection of the current event trigger.
This method is not supported and results in an exception.
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)
Re-evaluates the effective value for the specified dependency property(Inherited from DependencyObject.)
Returns the local value of a dependency property, if it exists. (Inherited from DependencyObject.)
Sets the value of a dependency property without changing its value source. (Inherited from DependencyObject.)
Sets the local value of a dependency property, specified by its dependency property identifier. (Inherited from DependencyObject.)
Returns whether serialization processes should serialize the effective value of the Actions property on instances of this class.
Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property.(Inherited from DependencyObject.)
Returns a string that represents the current object.(Inherited from Object.)
This API supports the product infrastructure and is not intended to be used directly from your code. Adds a child object.
This API supports the product infrastructure and is not intended to be used directly from your code. Adds the text content of a node to the object.
Trigger objects have the Setters, EnterActions, and ExitActions properties that apply changes or actions based on the state of certain properties, while objects start a set of Actions when a specified routed event occurs. For example, you may want to use an to start a set of animations when the mouse pointer is over a certain user interface (UI) control. Unlike Trigger, has no concept of termination of state, so the action will not be undone once the condition that raised the event is no longer true.
Note that when using an Button or TextBox perform specific actions on user input events such as mouse clicks and keyboard events. For example, if you are styling a button and try to set the MouseDown event as the RoutedEvent of an , the never gets applied because the event first gets handled by the button. Instead, you can use the PreviewMouseDown event or a different event., you need to choose events that do not interfere with the inherent behavior of your control. Controls such as
This example shows how to use event triggers in a style to animate the MouseEnter and MouseLeave events of a FrameworkElement. In this example, the Style has the TargetType set to Rectangle. Therefore, there is no need to qualify the MouseEnter and MouseLeave event names with the class name.
<Style TargetType="Rectangle"> <Setter Property="Width" Value="50" /> <Setter Property="Height" Value="50" /> <Setter Property="Margin" Value="20" /> <Setter Property="HorizontalAlignment" Value="Left" /> <Style.Triggers> <EventTrigger RoutedEvent="MouseEnter"> <BeginStoryboard> <Storyboard> <DoubleAnimation To="300" Duration="0:0:1.5" AccelerationRatio="0.10" DecelerationRatio="0.25" Storyboard.TargetProperty="(Canvas.Width)" /> </Storyboard> </BeginStoryboard> </EventTrigger> <EventTrigger RoutedEvent="MouseLeave"> <BeginStoryboard> <Storyboard> <DoubleAnimation Duration="0:0:1.5" AccelerationRatio="0.10" DecelerationRatio="0.25" Storyboard.TargetProperty="(Canvas.Width)" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Style.Triggers> </Style>
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.