0

无论如何,我是否有一个 PathGeometry 的旋转动画,它由从角度 A 到角度 B 的弧和线段(饼图)组成?

PathGeometry 是使用 c# 而不是 xaml 绘制的,因此在 c# 而不是 xaml 中的答案将不胜感激,并且动画需要在加载时播放。

4

1 回答 1

0

不确定我是否遗漏了什么:你不能只申请RotateTransformTransform然后为Angle属性设置动画吗?例如:

<Path Stroke="Black" StrokeThickness="5" Width="100" Height="100">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="RotationStates">
            <VisualState x:Name="RotatingState">
                <Storyboard Duration="0:0:1" RepeatBehavior="Forever" AutoReverse="True">
                    <DoubleAnimation Storyboard.TargetName="rotateTransform"
                                     Storyboard.TargetProperty="Angle"
                                     To="45"
                                     />
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <ei:GoToStateAction StateName="RotatingState" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <Path.Data>
        <PathGeometry>
            <PathGeometry.Transform>
                <RotateTransform x:Name="rotateTransform" Angle="0" />
            </PathGeometry.Transform>
            <PathFigure StartPoint="10,10">
                <LineSegment Point="50,0" />
            </PathFigure>
        </PathGeometry>
    </Path.Data>
</Path>
于 2014-07-30T18:57:14.767 回答