Storyboard.TargetProperty Attached Property
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Gets or sets the name of the property that should be animated.
Assembly: System.Windows (in System.Windows.dll)
'Declaration See GetTargetProperty, SetTargetProperty
See GetTargetProperty, SetTargetProperty
<object Storyboard.TargetProperty="simplePropertyName"/> - or - <object Storyboard.TargetProperty="propertyPath"/>
The property to animate.
Dependency property identifier field: TargetPropertyProperty
The value of Storyboard.TargetProperty must refer to an existing property of the element that is referenced by Storyboard.TargetName. For more information, see the "Creating a Storyboard" section of Animation Overview.
Storyboard.TargetProperty supports the concept of indirect property targeting, and uses a property path syntax to specify indirect targeting. Indirect property targeting is necessary when the type of the property that is being animated is itself an object, but the actual animated value is a property of that object instead of the object type itself. This is particularly necessary when markup cannot provide a name for targeting the sub-object, perhaps because it was specified originally in XAML attribute form instead of as a XAML object element. For example, to animate the Fill of a Rectangle using a linear interpolation of a SolidColorBrush, you would specify a ColorAnimation and give it a Storyboard.TargetProperty value of "(Rectangle.Fill).Color". For further details on this syntax, see Property Path Syntax.
Another scenario for using property paths is applying an animation to objects that are added to a collection at run time. In this case, you might name the object that holds the collection and then use the property path syntax to iterate to a specific index. In this way, you are able to target an animation to an object that has no name but that exists as a sub-property of a named object.
Attempting to set Storyboard.TargetProperty on a running animation will cause a run-time error. However, you can retarget existing animations that are stopped or not yet running. If you retarget animations, you usually want to use a target that is the same type, or that shares the property because of a base object definition. If you retarget an animation by changing Storyboard.TargetName, and Storyboard.TargetProperty references an unsupported property, you will get a run-time error.
The property you target must use the type of the animation that you are applying. For example, if you want to animate properties of an EllipseGeometry, you would use a DoubleAnimation (or DoubleAnimationUsingKeyFrames) to animate RadiusX or RadiusY, and a PointAnimation (or PointAnimationUsingKeyFrames) to animate Center. A mismatch of types will cause a parser error. The types must be exact matches; there is no implicit type conversion for animated properties. For example, you cannot animate a target of "(Canvas.ZIndex)" with a DoubleAnimation because Canvas.ZIndex takes an integer, not a double.
For the propertyName syntax that involves collections, the collection cannot be the last item in the property chain, because Silverlight object types contained in the collections cannot be directly animated with the Double, Color, and Point animation types that are supported in Silverlight. You must terminate the property chain with a specific property of the object that comes from an index in a collection.
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.