RepeatBehavior 구조체

정의

타임라인이 간단한 기간을 반복하는 방법을 설명합니다.

/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
struct RepeatBehavior
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public struct RepeatBehavior
Public Structure RepeatBehavior
<object property="iterationsx"/>
- or -
<object property="[days.]hours:minutes:seconds[.fractionalSeconds]"/>
- or -
<object property="Forever"/>
상속
RepeatBehavior
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

이 예제에서는 애니메이션의 RepeatBehavior 를 설정하는 여러 가지 방법과 이러한 설정이 애니메이션에 미치는 영향을 보여줍니다.

<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();
}

이 예제에서는 코드에서 RepeatBehavior 를 설정하는 방법을 보여줍니다. 애니메이션은 이전 예제와 동일하지만 x:Name 특성이 설정되고 RepeatBehavior가 XAML이 아닌 메서드에서 Start_Animation 설정됩니다.

<Storyboard x:Name="myStoryboard">

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

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

    <!-- Create an animation that repeats twice. -->
    <DoubleAnimation x:Name="TwiceRepeatingAnimation"
                     Storyboard.TargetName="TwiceRepeatingTransform" 
                     Storyboard.TargetProperty="ScaleX" 
                     From="1" To="5" Duration="0:0:2"  
                     EnableDependentAnimation="True"/>
</Storyboard>
private void Start_Animation(object sender, RoutedEventArgs e)
{
    // Set RepeatBehavior of Forever.
    var repeatBehavior = new RepeatBehavior();
    repeatBehavior.Type = RepeatBehaviorType.Forever;
    ForeverRepeatingAnimation.RepeatBehavior = repeatBehavior;

    // Set RepeatBehavior with Duration of 4 seconds.
    FourSecondsRepeatingAnimation.RepeatBehavior = new RepeatBehavior(new TimeSpan(0, 0, 4));

    // Set RepeatBehavior with Count of 2.
    TwiceRepeatingAnimation.RepeatBehavior = new RepeatBehavior(2);

    myStoryboard.Begin();
}

설명

RepeatBehavior 동작에는 다음 세 가지 유형이 있습니다.

  • 시간 범위: Timeline.Duration이 더 짧은 경우 애니메이션을 반복하는 타임라인의 활성 기간을 지정합니다. 예를 들어 간단한 Timeline.Duration 값이 1초이고 RepeatBehavior.Duration 값이 2.5초인 타임라인은 2.5회 반복 및 2.5초 동안 실행됩니다.
  • 반복 횟수: 타임라인 의 단순 재생 횟수를 지정합니다. 기본 반복 횟수는 1.0이며, 이는 타임라인 이 정확히 간단한 기간 중 하나에 대해 활성화되어 있다는 것을 의미합니다. 0.5 수가 2 수가 지정 타임 라인 두 번 단순 지속 시간을 반복 하는 동안 타임 라인의 단순 지속 시간을 절반에 대 한 활성 임을 지정 합니다. 자세한 내용은 개수를 참조하세요.
  • 영원히: 타임라인 은 무기한 반복됩니다.

RepeatBehavior는 두 가지 가능한 데이터 속성 개수 또는 기간 중 하나에 대해서만 0이 아닌 값을 포함해야 합니다. RepeatBehaviorTypeCount이면 RepeatBehavior의 Count 멤버가 관련 값입니다. RepeatBehaviorTypeDuration이면 RepeatBehavior의 Duration 멤버가 관련 값입니다. RepeatBehaviorTypeForever이면 CountDuration은 관련이 없습니다. 반복 동작은 대상 애니메이션이 제한 없이 지속적으로 반복되도록 하는 것입니다.

XAML 구문에 대한 참고 사항

ResourceDictionary에서 RepeatBehavior를 공유 가능한 개체로 선언할 수 없습니다.

RepeatBehavior의 프로젝션 및 멤버

Microsoft .NET 언어(C# 또는 Microsoft Visual Basic)를 사용하는 경우 RepeatBehavior에는 비데이터 멤버를 사용할 수 있으며 데이터 멤버 개수, 기간형식 은 필드가 아닌 읽기-쓰기 속성으로 노출됩니다.

Visual C++ 구성 요소 확장(C++/CX)을 사용하는 경우 RepeatBehavior에는 비데이터 멤버를 사용할 수 있으며 해당 데이터 멤버 개수, 기간형식 은 필드가 아닌 읽기 전용 속성으로 노출됩니다.

WINDOWS 런타임 WRL(템플릿 라이브러리)을 사용하여 C++로 프로그래밍하는 경우 데이터 멤버 필드 개수, 기간형식만 RepeatBehavior의 멤버로 존재하며 멤버 테이블에 나열된 유틸리티 메서드 또는 속성을 사용할 수 없습니다. WRL 코드는 RepeatBehaviorHelper 클래스에 있는 유사한 유틸리티 메서드에 액세스할 수 있습니다.

필드

Count

타임라인이 반복되어야 하는 횟수입니다.

Duration

타임라인이 반복되어야 하는 시간 범위입니다.

Type

이 instance 나타내는 반복 동작의 모드 또는 유형(열거형 값)입니다.

적용 대상