Represents a trigger that applies a set of actions (animation storyboards) in response to an event.
To create an object using scripting, see CreateFromXAML.
|oneOrMoreBeginStoryboards||One or more BeginStoryboard object elements. Object elements defined here become members of the collection held by the Actions property, when accessed by scripting at runtime.|
You do not typically specify Actions as an explicit property element in XAML, because it is the default collection property of an EventTrigger. You will set the Actions value in XAML by placing one or more BeginStoryboard elements as the child elements of an EventTrigger object element.
EventTrigger itself is always a child element of the <object.Triggers> property element when specified in XAML. The Triggers property is a case where the property element syntax is required to set it in XAML.
In Silverlight 1.0, the only event that you can use for an EventTrigger is the Loaded event. For other events, you should declare a storyboard in Resources, provide the storyboard a Name, and write an event handler that calls Begin on the named storyboard. For details, see Interactive Animations Overview.
The following example shows how to use a Storyboard and an EventTrigger to make a rectangle that fades in and out of view after it is loaded.
<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Rectangle x:Name="MyAnimatedRectangle" Width="100" Height="100" Fill="Blue"> <Rectangle.Triggers> <!-- Animates the rectangle's opacity. --> <EventTrigger RoutedEvent="Rectangle.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="MyAnimatedRectangle" Storyboard.TargetProperty="Opacity" From="1.0" To="0.0" Duration="0:0:5" AutoReverse="True" RepeatBehavior="Forever" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Rectangle.Triggers> </Rectangle> </Canvas>