RepeatBehavior structure

This topic has not yet been rated - Rate this topic

Describes how a Timeline repeats its simple duration.

Syntax


public struct RepeatBehavior


<object property="iterationsx"/>
- or -
<object property="[days.]hours:minutes:seconds[.fractionalSeconds]"/>
- or -
<object property="Forever"/>

XAML Values

iterationsx

The iterations placeholder in the iterations form is an integer, specifying the number of times that an animation should repeat. The x is a literal, lower-case character x. (A way to remember this convention is to think of x as a multiplication character, that is, "3x" means "3 times".) Iterations set the Count data; a TimeSpan value does not set the Count data.

days

Optional. An integer value greater than or equal to 0 that specifies the number of days.

hours

Required, even if 0. An integer value between 0 and 23 that specifies the number of hours.

minutes

Optional if only hours are desired, but must be set to at least 0 if you intend to set a seconds value. An integer value between 0 and 59 that specifies the number of minutes.

seconds

Optional if only hours/minutes are desired. An integer value between 0 and 59 that specifies the number of seconds.

fractionalSeconds

Optional. A value consisting of 1 to 7 digits of decimal precision that specifies fractional seconds.

Forever

The literal "Forever"; see Remarks.

Attributes

VersionAttribute(NTDDI_WIN8)
WebHostHiddenAttribute()

Members

The RepeatBehavior structure has these types of members:

Constructors

The RepeatBehavior structure has these constructors.

ConstructorDescription
RepeatBehavior(Double) [C#, VB]Initializes a new instance of the RepeatBehavior structure with the specified iteration count.
RepeatBehavior(TimeSpan) [C#, VB]Initializes a new instance of the RepeatBehavior structure with the specified repeat duration.

 

Fields

The RepeatBehavior structure has these fields.

FieldData typeDescription
Count [C++]

System.Double [.NET] | float64 [C++]

The number of times a Timeline should repeat.

Duration [C++]

System.TimeSpan [.NET] | Windows::Foundation::TimeSpan [C++]

The time span for which a Timeline should repeat.

Type [C++]

RepeatBehaviorType

The mode or type of repeat behavior that this instance represents, as a value of the enumeration.

 

Methods

The RepeatBehavior structure has these methods. It also inherits methods from the Object class.

MethodDescription
Equals(Object) [C#, VB]Determines whether the specified object is equal to a RepeatBehavior.
Equals(RepeatBehavior) [C#, VB]Compares two RepeatBehavior structures for equality.
Equals(RepeatBehavior,RepeatBehavior) [C#, VB]Compares two RepeatBehavior structures for equality, as a static helper method.
GetHashCode [C#, VB]Gets a hash code for this object.
ToString [C#, VB]Converts a RepeatBehavior to a String representation.
ToString(IFormatProvider) [C#, VB]Creates a String representation of this RepeatBehavior.

 

Operators

The RepeatBehavior structure has these operators.

OperatorDescription
Equality Compares two RepeatBehavior structures for equality.
Inequality Compares two RepeatBehavior structures for inequality.

 

Properties

The RepeatBehavior structure has these properties.

PropertyAccess typeDescription

Count [C#, VB]

Read/writeGets the number of times that a Timeline should repeat.

Duration [C#, VB]

Read/writeGets the total length of time that a Timeline should play.

Forever [C#, VB]

Read-onlyGets a RepeatBehavior that specifies an infinite number of repetitions.

HasCount [C#, VB]

Read-onlyGets a value that indicates whether the repeat behavior has a specified iteration count.

HasDuration [C#, VB]

Read-onlyGets a value that indicates whether the repeat behavior has a specified repeat duration.

Type [C#, VB]

Read/writeGets or sets one of the RepeatBehaviorType values that describes the way behavior repeats.

 

Remarks

There are three types of RepeatBehavior behaviors:

  • Time span: specifies the active duration of a Timeline, possibly repeating the animation if the Timeline.Duration is shorter. For example, a Timeline with a simple Timeline.Duration value of 1 second and a RepeatBehavior.Duration value of 2.5 seconds will run for 2.5 iterations, and 2.5 seconds.
  • Iteration count: specifies the number of times the simple duration of a Timeline plays. The default iteration count is 1.0, and this means the Timeline is active for exactly one of its simple durations. A count of 0.5 specifies that the timeline is active for half of its simple duration, while a count of 2 specifies that the timeline repeats its simple duration twice. For more information, see Count.
  • Forever: the Timeline repeats indefinitely.

A RepeatBehavior should only contain non-zero values for one of its two possible data properties Count or Duration. If the RepeatBehaviorType is Count, then the Count member of a RepeatBehavior is the relevant value. If the RepeatBehaviorType is Duration, then the Duration member of a RepeatBehavior is the relevant value. If the RepeatBehaviorType is Forever, then neither Count nor Duration are relevant; the repeat behavior is such that the targeted animation will repeat continuously without a limit.

Notes on XAML syntax

You cannot declare a RepeatBehavior as a shareable object in a ResourceDictionary.

Projection and members of RepeatBehavior

If you are using a Microsoft .NET language (C# or Microsoft Visual Basic), or in Visual C++ component extensions (C++/CX), then RepeatBehavior has non-data members available, and its data members Count, Duration and Type are exposed as read-write properties, not fields.

If you are programming with C++ using the Windows Runtime Template Library (WRL), then only the data member fields Count, Duration, and Type exist as members of RepeatBehavior, and you cannot use the utility methods or properties listed in the members table. WRL code can access similar utility methods that exist on the RepeatBehaviorHelper class.

Examples

This example shows several different ways to set the RepeatBehavior of an animation and how these settings can affect your animation.


<StackPanel Margin="20">
    <StackPanel.Resources>
        <Storyboard x:Name="myStoryboard">

            <!-- Create an animation that repeats indefinitely. -->
            <DoubleAnimation 
              Storyboard.TargetName="ForeverRepeatingTransform" 
              Storyboard.TargetProperty="ScaleX" 
              From="1" To="5" Duration="0:0:2" RepeatBehavior="Forever" />

            <!-- Create an animation that repeats for four seconds. Because
                 the animation is 2 seconds each, you get two repeats. -->
            <DoubleAnimation 
              Storyboard.TargetName="FourSecondsRepeatingTransform" 
              Storyboard.TargetProperty="ScaleX"
              From="1" To="5" Duration="0:0:2" RepeatBehavior="0:0:4" 
              EnableDependentAnimation="True"/>

            <!-- Create an animation that repeats twice. -->
            <DoubleAnimation 
              Storyboard.TargetName="TwiceRepeatingTransform" 
              Storyboard.TargetProperty="ScaleX" 
              From="1" To="5" Duration="0:0:2" RepeatBehavior="2x" 
              EnableDependentAnimation="True"/>

            <!-- Create an animation that repeats 0.5 times. The resulting animation
                 plays for one second, half of its Duration. It animates from 50 to 150. -->
            <DoubleAnimation 
              Storyboard.TargetName="HalfRepeatingTransform" 
              Storyboard.TargetProperty="ScaleX" 
              From="1" To="5" Duration="0:0:2" RepeatBehavior="0.5x" 
              EnableDependentAnimation="True"/>

            <!-- Create an animation that repeats for one second. The resulting animation
                 plays for one second, half of its Duration. It animates from 50 to 150. -->
            <DoubleAnimation 
              Storyboard.TargetName="OneSecondRepeatingTransform" 
              Storyboard.TargetProperty="ScaleX" 
              From="1" To="5" Duration="0:0:2" RepeatBehavior="0:0:1" 
              EnableDependentAnimation="True"/>
        </Storyboard>
    </StackPanel.Resources>

    <!-- Create several rectangles to animate. -->
    <Rectangle Fill="Red" Width="50" Height="20" >
        <Rectangle.RenderTransform>
            <ScaleTransform x:Name="ForeverRepeatingTransform" />
        </Rectangle.RenderTransform>
   </Rectangle>
   <Rectangle Fill="Blue" Width="50" Height="20" >
       <Rectangle.RenderTransform>
           <ScaleTransform x:Name="FourSecondsRepeatingTransform" />
       </Rectangle.RenderTransform>
   </Rectangle>
   <Rectangle Fill="Yellow" Width="50" Height="20" >
       <Rectangle.RenderTransform>
           <ScaleTransform x:Name="TwiceRepeatingTransform" />
       </Rectangle.RenderTransform>
   </Rectangle>
   <Rectangle Fill="Green" Width="50" Height="20" >
       <Rectangle.RenderTransform>
           <ScaleTransform x:Name="HalfRepeatingTransform" />
       </Rectangle.RenderTransform>
   </Rectangle>
   <Rectangle Fill="Orange" Width="50" Height="20" >
       <Rectangle.RenderTransform>
           <ScaleTransform x:Name="OneSecondRepeatingTransform" />
       </Rectangle.RenderTransform>
   </Rectangle>

        <!-- Create buttons to restart and stop the animations. -->
   <Button Margin="10" Content="Restart Animation" Click="Start_Animation" />


</StackPanel>



private void Start_Animation(object sender, RoutedEventArgs e)
{
    myStoryboard.Begin();
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Namespace

Windows.UI.Xaml.Media.Animation
Windows::UI::Xaml::Media::Animation [C++]

Metadata

Windows.winmd

 

 

Build date: 12/4/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.