RoutedEvent Property
Collapse the table of content
Expand the table of content

EventTrigger.RoutedEvent Property


Gets or sets the RoutedEvent that will activate this trigger.

Namespace:   System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)

public RoutedEvent RoutedEvent { get; set; }

Property Value

Type: System.Windows.RoutedEvent

The default value is null.

Exception Condition

The RoutedEvent property cannot be null.

EventTriggers apply a set of actions when the specified occurs. For example, you may want to use EventTriggers to start a set of animations when the mouse pointer is over a certain user interface (UI) control.GTMT

If the template or style that contains this EventTrigger does not have the TargetType property specified, then you need to quality the event name with the class name using the ClassName.EventName syntax.

EventTrigger objects cannot handle events that have already been Handled. Controls such as 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 EventTrigger, the EventTrigger never gets applied because the event first gets handled by the button. Instead, you can use the PreviewMouseDown event or a different event.

When using data binding, if you are using the TargetUpdated event, you must set the NotifyOnTargetUpdated value of your Binding object to true for the event to be raised.

Legacy Code Example

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.

Code snippet is not found. Confirm that the code snippet name 'StyleEventTriggerAnimation' is correct.Code snippet is not found. Confirm that the code snippet name 'HOWDOI' is correct.

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2015 Microsoft