Export (0) Print
Expand All
Key
M11
M12
M21
M22
Tag
Uri
X1
X2
Y1
Y2
Expand Minimize

Resources

Silverlight

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

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.

Type: ResourceDictionary

A collection of Storyboard objects.

This property is read/write. The default value is an empty collection.

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.

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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://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();

}

Community Additions

ADD
Show:
© 2015 Microsoft