EventTrigger class
Represents a trigger that applies a set of actions (animation storyboards) in response to an event. Not commonly used. See Remarks.
Inheritance
- Object
- DependencyObject
- TriggerBase
- EventTrigger
Syntax
<EventTrigger> oneOrMoreBeginStoryboards </EventTrigger>
XAML Values
- oneOrMoreBeginStoryboards
-
One or more BeginStoryboard object elements. Object elements defined here become members of the list that is the value of the Actions property, if you use code to examine that collection at run time.
Attributes
- ActivatableAttribute(NTDDI_WIN8)
- ContentPropertyAttribute(Name=Actions)
- MarshalingBehaviorAttribute(Agile)
- ThreadingAttribute(Both)
- VersionAttribute(NTDDI_WIN8)
- WebHostHiddenAttribute()
Members
The EventTrigger class has these types of members:
Constructors
The EventTrigger class has these constructors.
| Constructor | Description |
|---|---|
| EventTrigger | Initializes a new instance of the EventTrigger class. |
Methods
The EventTrigger class has these methods. It also inherits methods from the Object class.
| Method | Description |
|---|---|
| ClearValue | Clears the local value of a dependency property. (Inherited from DependencyObject) |
| GetAnimationBaseValue | Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject) |
| GetValue | Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject) |
| ReadLocalValue | Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject) |
| SetValue | Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject) |
Properties
The EventTrigger class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read-only | Gets the collection of BeginStoryboard objects that this EventTrigger maintains. | |
| Read-only | Gets the CoreDispatcher that this object is associated with. (Inherited from DependencyObject) | |
| Read/write | Gets or sets the name of the event that initiates the trigger. |
Remarks
Triggers, EventTrigger, Actions and BeginStoryboard are not commonly used. These APIs mainly exist for compatibility in XAML originally used for Microsoft Silverlight. For most scenarios where event triggers were used previously, do one of these:
- Use built-in animations. See Quickstart: Animating your UI.
- For events in control templates, use visual states and VisualStateManager.
- For app-specific UI animations, define a Loaded handler on the page. This handler can reference a Storyboard that's defined in page-level resources, and call the Begin method on that Storyboard.
If you do choose to use Triggers, in Windows Runtime XAML, the default behavior for event triggers and the only event that can be used to invoke an EventTrigger is FrameworkElement.Loaded. Because that's both the default and the only enabled behavior, don't set the RoutedEvent attribute. Just use the XAML <EventTrigger>. For more info, see Triggers.
Examples
This XAML example shows the basic structure for using FrameworkElement.Triggers with its default FrameworkElement.Loaded trigger behavior to run a storyboarded animation. This XAML shows the EventTrigger and BeginStoryboard container elements in proper relationship with each using their XAML content property syntax and unnecessary property element tags omitted.
<Canvas Width="200" Height="200" x:Name="animatedcanvas" Background="Red"> <Canvas.Triggers> <EventTrigger> <BeginStoryboard> <Storyboard x:Name="ColorStoryboard"> <!-- Animate the background of the canvas to green over 4 seconds. --> <ColorAnimation Storyboard.TargetName="animatedcanvas" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" To="Green" Duration="0:0:4" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Canvas.Triggers> </Canvas>
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 1/31/2013
