2017-01-20 5 views
0

У меня есть приложение WPF, которое содержит эллипс, который имеет круговую анимацию. Анимация работает только 2 секунды, и я бы хотел, чтобы она бежала, пока я не скажу, что раскадровка остановится.wpf раскадровка анимация длится всего 2 секунды

Это ресурс Словарь Раскадровка Определение:

<Storyboard x:Key="AnimateCircle" Duration="00:05:00"> 
     <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="{Binding}"> 
      <EasingColorKeyFrame KeyTime="0" Value="#FF212121"/> 
     </ColorAnimationUsingKeyFrames> 
     <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="{Binding}"> 
      <EasingColorKeyFrame KeyTime="0" Value="#FFF7F4F5"/> 
     </ColorAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="{Binding}" Duration="00:05:00"> 
      <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:2" Value="359"/> 
     </DoubleAnimationUsingKeyFrames> 
    </Storyboard> 

Это мой WPF XAML код:

  <Ellipse 
       Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" 
       x:Name="AnimationCircle" 
       Margin="0,0,0,0" 
       Height="200" Width="200" 
       StrokeThickness="30" 
       Visibility="Visible" 
       RenderTransformOrigin="0.5,0.5"> 
       <Ellipse.RenderTransform> 
        <TransformGroup> 
         <ScaleTransform/> 
         <SkewTransform/> 
         <RotateTransform/> 
         <TranslateTransform/> 
        </TransformGroup> 
       </Ellipse.RenderTransform> 
       <Ellipse.Stroke> 
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
         <GradientStop Color="#FF212121" Offset="0"/> 
         <GradientStop Color="#FFF7F4F5" Offset="1"/> 
        </LinearGradientBrush> 
       </Ellipse.Stroke> 
      </Ellipse> 

Это WPF C# код позади, чтобы начать анимацию:

sb = this.FindResource("AnimateCircle") as Storyboard; 
Storyboard.SetTarget(sb, AnimationCircle); 
sb.Begin(this); 

ответ

3

Удалить Duration="00:05:00" из Раскадровка и изменить DoubleAnimationUsingKeyFrames вот так

<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="{Binding}" RepeatBehavior="Forever"> 
      <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:2" Value="359"/> 
     </DoubleAnimationUsingKeyFrames>