Skip to main content
IUIAnimationStoryboard2::RepeatBetweenKeyframes method

Creates a loop between two keyframes.


HRESULT RepeatBetweenKeyframes(
  [in] UI_ANIMATION_KEYFRAME                   startKeyframe,
  [in] UI_ANIMATION_KEYFRAME                   endKeyframe,
  [in] DOUBLE                                  cRepetition,
  [in] UI_ANIMATION_REPEAT_MODE                repeatMode,
  [in] IUIAnimationLoopIterationChangeHandler2 *pIterationChangeHandler = 0,
  [in] UINT_PTR                                id = 0,
  [in] BOOL                                    fRegisterForNextAnimationEvent = 0


startKeyframe [in]

The keyframe at which the loop is to begin.

endKeyframe [in]

The keyframe at which the loop is to end. endKeyframe must not occur earlier in the storyboard than startKeyframe.

cRepetition [in]

The number of times the loop is to be repeated; the last iteration of a loop can terminate fractionally between keyframes. A value of zero indicates that the specified portion of a storyboard will not be played. A value of UI_ANIMATION_REPEAT_INDEFINITELY (-1) indicates that the loop will repeat indefinitely until the storyboard is trimmed or concluded.

repeatMode [in]

The pattern for the loop iteration.

A value of UI_ANIMATION_REPEAT_MODE_ALTERNATE (1) specifies that the start of the loop must alternate between keyframes (k1->k2, k2->k1, k1->k2, and so on).

A value of UI_ANIMATION_REPEAT_MODE_NORMAL (0) specifies that the start of the loop must begin with the first keyframe (k1->k2, k1->k2, k1->k2, and so on).

Note  If repeatMode has a value of UI_ANIMATION_REPEAT_MODE_ALTERNATE (1) and cRepetition has a value of UI_ANIMATION_REPEAT_INDEFINITELY (-1), the loop terminates on the end keyframe.
pIterationChangeHandler [in]

The handler for each loop iteration event. The default value is 0.

id [in]

The loop ID to pass to pIterationChangeHandler. The default value is 0.

fRegisterForNextAnimationEvent [in]

If true, specifies that pIterationChangeHandler will be incorporated into the estimate of the time interval until the next animation event that is returned by the IUIAnimationManager2::EstimateNextEventTime method. The default value is 0, or false.

Return value

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. See Windows Animation Error Codes for a list of error codes.


This method directs a storyboard to play the interval between the given keyframes repeatedly before playing the remainder of the storyboard. If a finite repetition count is specified, the loop always plays that number of times. If UI_ANIMATION_REPEAT_INDEFINITELY (-1) is specified, the loop repeats until the storyboard is concluded, in which case the current iteration of the loop completes and the remainder of the storyboard plays. A storyboard that loops indefinitely also ends if it is truncated.

Nested and overlapping loops are not supported.

A keyframe represents a moment in time within a storyboard and can be used to specify the start or end times of transitions. Because keyframes can be added at the ends of transitions, their offsets from the start of the storyboard may not be known until the storyboard is playing.


Minimum supported client

Windows 8, Windows 7 and Platform Update for Windows 7 [desktop apps | Windows Store apps]

Minimum supported server

None supported








IID_IUIAnimationStoryboard2 is defined as AE289CD2-12D4-4945-9419-9E41BE034DF2

See also