MatrixAnimationUsingPath.IsAngleCumulative 属性

定义

获取或设置一个值,该值指定动画矩阵的旋转角度是否应随着重复累计。

public:
 property bool IsAngleCumulative { bool get(); void set(bool value); };
public bool IsAngleCumulative { get; set; }
member this.IsAngleCumulative : bool with get, set
Public Property IsAngleCumulative As Boolean

属性值

如果动画的旋转角度应随着重复累计,则为true;否则为 false。 默认值为 false

示例

以下示例使用两个类似的 MatrixAnimationUsingPath 动画对同一矩形进行动画处理。 这两个动画具有相同 PathGeometry 的设置,这会导致矩形在沿屏幕向右移动时旋转,并且两个动画都设置为重复四次。 第一个动画的 IsAngleCumulative 属性设置为 false,因此当动画重复时,矩形将跳回其原始角度。 第二个动画的 IsAngleCumulative 属性设置为 true;因此,当动画重复时,矩形角度似乎会增加,而不是跳转回其原始值。

<Page 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
  <StackPanel Margin="50">
      
    <!-- The Rectangle that is animated across the screen by animating
         the MatrixTransform applied to the button. -->
    <Rectangle 
      Width="75" Height="25"
      HorizontalAlignment="Left"
      VerticalAlignment="Top"
      Stroke="Black" StrokeThickness="1">
      <Rectangle.RenderTransform>
        <MatrixTransform x:Name="myMatrixTransform">
          <MatrixTransform.Matrix >
            <Matrix OffsetX="10" OffsetY="100"/>
          </MatrixTransform.Matrix>
        </MatrixTransform>
      </Rectangle.RenderTransform>
      <Rectangle.Fill>
        <LinearGradientBrush>
          <GradientStop Color="Lime" Offset="0.0" />
          <GradientStop Color="Gray" Offset="1.0" />
        </LinearGradientBrush>
      </Rectangle.Fill>
    </Rectangle>

    <!-- Shows the animation path. -->
    <Path
      Stroke="Black" StrokeThickness="5"
      Data="M 0,0 A 50,50 0 1 0 100,0" />
    
    <StackPanel Margin="0,200,0,0" Orientation="Horizontal">
    <Button Content="Animate with IsAngleCumulative set to False"
      HorizontalAlignment="Left" Padding="5">
      <Button.Triggers>
        <EventTrigger RoutedEvent="Button.Click">
          <BeginStoryboard>
            <Storyboard>

              <!-- The angle generated by this animation does not
                   accumulate over repetitions. As a result, 
                   the rectangle appears to jump back to its 
                   starting angle when the animation repeats.  -->
              <MatrixAnimationUsingPath
                Storyboard.TargetName="myMatrixTransform"
                Storyboard.TargetProperty="Matrix"
                Duration="0:0:2" 
                RepeatBehavior="4x" 
                IsOffsetCumulative="True" 
                IsAngleCumulative="False"
                DoesRotateWithTangent="True">
                <MatrixAnimationUsingPath.PathGeometry>
                  <PathGeometry Figures="M 0,0 A 50,50 0 1 0 100,0" />
                </MatrixAnimationUsingPath.PathGeometry>
              </MatrixAnimationUsingPath>
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </Button.Triggers>   
    </Button>
    
     <Button Content="Animate with IsAngleCumulative set to True"
      HorizontalAlignment="Left" 
      Padding="5">
      <Button.Triggers>
        <EventTrigger RoutedEvent="Button.Click">
          <BeginStoryboard>
            <Storyboard>
            
              <!-- The angle generated by this animation accumulates
                   over repetitions. As a result, the rectangle's
                   rotation appears seamless.  -->
              <MatrixAnimationUsingPath
                Storyboard.TargetName="myMatrixTransform"
                Storyboard.TargetProperty="Matrix"
                Duration="0:0:2" 
                RepeatBehavior="4x" 
                IsOffsetCumulative="True" 
                IsAngleCumulative="True"
                DoesRotateWithTangent="True">
                <MatrixAnimationUsingPath.PathGeometry>
                  <PathGeometry Figures="M 0,0 A 50,50 0 1 0 100,0" />
                </MatrixAnimationUsingPath.PathGeometry>
              </MatrixAnimationUsingPath>
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </Button.Triggers>   
    </Button>   
    </StackPanel>
    
    
  </StackPanel>
</Page>

注解

如果此属性设置为 true,则动画矩阵的旋转角度将随着动画重复而累积。 如果路径是一个小弧线,累积角度将导致对象在每次重复时持续旋转,而不是重新启动旋转。 与 IsOffsetCumulativetrue结合使用时,对象在 (弹跳时可能看起来会翻滚,具体取决于) 指定的路径。 有关相关信息,请参阅IsOffsetCumulative

如果 DoesRotateWithTangentfalse,则设置此属性不起作用。

此属性确定动画矩阵的角度在动画重复时是否因为其 RepeatBehavior 设置而累积;它不会导致动画重启时偏移量累积。 有关如何根据上一个动画的值生成动画的信息,请参阅 IsAdditive

依赖项属性信息

标识符字段 IsAngleCumulativeProperty
元数据属性设置为 true

适用于

另请参阅