Resources
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Gets or sets a collection of Storyboard objects that you can use to control animations.
<object>
<object.Resources>
oneOrMoreNamedStoryboards
</object.Resources>
<object>
value = object.Resources
object.Resources = value
XAML Values
Value |
Description |
---|---|
oneOrMoreNamedStoryboards |
One or more Storyboard object elements. Each Storyboard object element must specify the Name or x:Name attribute, and each Name or x:Name attribute value must be unique. |
Property Value
Type: ResourceDictionary
A collection of Storyboard objects.
This property is read/write. The default value is an empty collection.
Remarks
Unlike a Storyboard that is associated with an EventTrigger, a Storyboard that is defined as a resource does not start automatically. You can retrieve a reference to the Storyboard by assigning it a name and using the FindName method. You can then control the Storyboard by using its interactive methods: Begin, Pause, Resume, and Stop.
The XAML syntax for the Resources property is an example of an implicit collection syntax. For scripting, the property type of the property is ResourceDictionary, but you can omit the ResourceDictionary opening and closing tags in your markup because they are implicit. Instead, you include one or more Storyboard elements as child elements of object.Resources.
Example
The following example makes a rectangle fade from view when the user presses the left mouse button over it. Because it is defined as a resource, the animation does not start automatically.
<Canvas
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml">
<Canvas.Resources>
<Storyboard x:Name="myStoryboard">
<DoubleAnimation
Storyboard.TargetName="MyAnimatedRectangle"
Storyboard.TargetProperty="Opacity"
From="1.0" To="0.0" Duration="0:0:5"
AutoReverse="True" />
</Storyboard>
</Canvas.Resources>
<Rectangle
x:Name="MyAnimatedRectangle"
Width="100"
Height="100"
Fill="Blue"
MouseLeftButtonDown="startAnimation">
</Rectangle>
</Canvas>
function startAnimation(sender, mouseEventArgs)
{
// Retrieve the Storyboard and begin it.
sender.findName("myStoryboard").begin();
}
Applies To
Border (Silverlight 2)
PasswordBox (Silverlight 2)
Popup (Silverlight 2)
StackPanel (Silverlight 2)
TextBox (Silverlight 2)