Storyboard.TargetName Property

Gets or sets the name of the object to animate.

XAML
<object Storyboard.TargetName="string" .../>
Scripting
value = object["Storyboard.TargetName"]
object["Storyboard.TargetName"] = value

Property Value

string

The name of the object to animate.

This property is read/write. The default value is null.

Remarks

This property is an example of an attached property, whereby non-Storyboard objects can set this Storyboard-specific property.

Notice particularly the script syntax, which resembles an indexer or array syntax. The ["ownerType.propertyName"] form (with no dot separating this property form and the target object for getting or setting) is necessary to get or set an attached property such as Storyboard.TargetName in script.

The value of Storyboard.TargetName must refer to an existing element that has that same string assigned as its Name or x:Name attribute. For details, see the "Part 2: Create a Storyboard" section of Animation Overview.

Attempting to set Storyboard.TargetName on a running animation will raise a runtime SetValue method error. You can however use script to retarget existing animations that are not yet running. If you do so, be cautious because if you retarget an animation to the wrong type of target (one that does not possess the existing Storyboard.TargetProperty) you will get a runtime error.

Applies To

ColorAnimation, ColorAnimationUsingKeyFrames, DoubleAnimation, DoubleAnimationUsingKeyFrames, PointAnimation, PointAnimationUsingKeyFrames, Storyboard

See Also

Animation Overview