Compartir a través de


RepeatBehavior

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

Describes how a Timeline object repeats its simple duration.

<object property="repeatBehaviorString"  .../>
object.property="repeatBehaviorString"

repeatBehaviorString Grammar

Type

Grammar

Example

Example result

Time span

[days.]hours:minutes:seconds[.fractionalSeconds]

"0:0:15"

Will repeat for 15 seconds.

Iterations

iterationsx

"3x"

Will repeat three times.

Literal "Forever"

Forever

"Forever"

Runs continuously.

  • In the grammar above, square brackets ([]) indicate optional values; the brackets are not literals. The colon (:) and period (.) characters are both literals, as is the lowercase x in the iterations form.

  • Values for hours can be any integer value from 0 through 23. Values for minutes and seconds can be any integer value from 0 through 59. The value for days can be very large, but it does have an unspecified upper bound. The decimal value for fractionalSeconds (with the decimal point included) must be between 0 and 1.

  • The iterations placeholder in the iterations form is an integer, specifying the number of times that an animation should repeat. The number of iterations is always followed by the literal lower-case character x. (A way to remember this convention is to think of it as a multiplication character, i.e. "3x" means "3 times.")

  • Forever is a literal string that holds special meaning for a RepeatBehavior. For more information, see Animation Overview (Silverlight 1.0).

Managed Equivalent

RepeatBehavior

Remarks

You can create a Duration, KeyTime, RepeatBehavior, or TimeSpan object in XAML or in script only through a type conversion syntax when you set a property (such as RepeatBehavior) that takes one of these types, with the value specified as a string. The string format for specifying a time in each of these types is identical. Duration can also take the literals Automatic and Forever. RepeatBehavior can take the literal Forever and also an iterations syntax iterationsx. The iterations syntax uses an integer to specify the number of times the animation should repeat, immediately followed by the literal lowercase character x (case-sensitive).

The main scenario for working with a RepeatBehavior as an object in script is to get or set its Seconds property to query or change an existing animation value.

The typical time span of an animation is in seconds. Therefore, the RepeatBehavior string would include preceding 0 values for hours and minutes, along with the appropriate literal characters—colons (:) and periods (.)—as separators between hours, minutes, seconds, and fractions of seconds. For example, to specify a RepeatBehavior of 5 seconds, you would set the RepeatBehavior string to "0:0:5" ("0:0:05" is equivalent).

Important noteImportant Note:

If you specify a RepeatBehavior by an integer without any time span literal characters—colons (:) or periods (.)—the integer will be interpreted only as a number of days. This is seldom the intended result and will typically cause the RepeatBehavior to be unexpectedly large.

If the RepeatBehavior is set as Forever, or is set by using the iterationsx form, the value of the Seconds property will be 0.

For more information on basic concepts, see Animation Overview. Note that the Animation Overview topic is written primarily for users of the managed API, and may not have code examples or specific information that address the JavaScript API scenarios.

See Also

Reference