Partager via


Storyboard.TargetName

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the name of the object to animate.

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

Property Value

Type: string

The name of the object to animate.

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

Managed Equivalent

Storyboard.TargetName

Remarks

Storyboard.TargetName is an example of a Storyboard-specific attached property, which non-Storyboard objects can set.

Notice 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.

Attempting to set Storyboard.TargetName on a running animation will raise a run-time SetValue method error. However, you can use scripting to retarget existing animations that are not yet running. If you do so, be careful not to retarget an animation to the wrong type of target (one that does not possess the existing Storyboard.TargetProperty). Otherwise, you will get a run-time error.