c# wpf旋转动画饼切片(使用PathGeometry绘制)

本文关键字:使用 PathGeometry 绘制 切片 wpf 旋转 动画 | 更新日期: 2023-09-27 18:15:46

无论如何我有一个旋转动画的PathGeometry,由弧和线段(饼)从角度a到角度B?

PathGeometry是用c#而不是xaml绘制的,所以用c#而不是xaml的答案会很受欢迎,并且动画需要在加载时播放

c# wpf旋转动画饼切片(使用PathGeometry绘制)

不确定我是否错过了什么:你不能把RotateTransform应用到Transform,然后动画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>