在WPF中使用ArcSegment创建倒计时圈

时间:2014-02-12 15:15:25

标签: c# wpf animation countdown

我正在尝试倒计时圈。但我无法让它发挥作用。我能做的就是创建一个填充圈,但不能用于倒计时。希望代码清楚。 我想要做的就是反向动画的功能(在代码中注释)

<UserControl.Triggers>
    <EventTrigger RoutedEvent="Page.Loaded">
        <BeginStoryboard>
            <Storyboard >
                <!--RepeatBehavior="Forever"
                AutoReverse="True" >-->
                <PointAnimationUsingPath
                        Storyboard.TargetName="arc"
                        Storyboard.TargetProperty="Point"
                        Duration="0:0:5">
                    <PointAnimationUsingPath.PathGeometry>
                        <PathGeometry>
                            <PathFigure StartPoint="200 100">
                                <ArcSegment Size="100 100" Point="200 300" SweepDirection="Clockwise"  />
                                <ArcSegment Size="100 100" Point="200 100" SweepDirection="Clockwise" />
                            </PathFigure>
                        </PathGeometry>
                    </PointAnimationUsingPath.PathGeometry>
                </PointAnimationUsingPath>

                <BooleanAnimationUsingKeyFrames
                        Storyboard.TargetName="arc"
                        Storyboard.TargetProperty="IsLargeArc">
                    <DiscreteBooleanKeyFrame KeyTime="0:0:2.5" Value="True" />
                    <DiscreteBooleanKeyFrame KeyTime="0:0:5" Value="False" />
                </BooleanAnimationUsingKeyFrames>
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
</UserControl.Triggers>

<Path Stroke="Blue" StrokeThickness="3" Fill="Transparent">
    <Path.Data>
        <PathGeometry>
            <PathFigure StartPoint="200 100" IsClosed="False">
                <ArcSegment x:Name="arc" Size="100 100" SweepDirection="Clockwise" />
            </PathFigure>
        </PathGeometry>
    </Path.Data>
</Path>

1 个答案:

答案 0 :(得分:0)

我终于设法使用一个ArcSegment来解决它,动画点的端点与起点不同.01和更改IsLargeArc的离散布尔动画的时间,尽管我经历过ArcSegment有时表现不同但没有更改代码