gpt4 book ai didi

c# - 是否可以为 path.Data 设置动画

转载 作者:行者123 更新时间:2023-11-30 19:55:38 25 4
gpt4 key购买 nike

我有这样的代码:

<Path x:Name="arrow" StrokeThickness="3" Stroke="Black"  Data="M34,115 C45,106 91,119 105,112 119,105 172,75.004352 188,82.003591" />

我想要的是为路径的数据属性设置动画。我从最近两天开始搜索这个没有找到解决方案。我真正想要的是一点一点地显示路径。

有没有人有什么想法?

最佳答案

“我真正想要的是一点一点地显示路径”

你的意思是这样的吗?

<Grid VerticalAlignment="Center" HorizontalAlignment="Center" >
<Grid.Resources>
<Storyboard x:Key="CWTrace">
<!-- To run opposite direction, just swap the 'From' and 'To' values. -->
<DoubleAnimation BeginTime="00:00:0.5" RepeatBehavior="Forever"
Storyboard.TargetName="arrow"
Storyboard.TargetProperty="StrokeDashOffset"
Duration="0:0:5" From="100" To="0"/>
</Storyboard>
</Grid.Resources>
<Grid.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource CWTrace}"/>
</EventTrigger>
</Grid.Triggers>
<Path x:Name="arrow"
StrokeDashOffset="0" StrokeDashArray="100"
StrokeThickness="3" Stroke="Black"
Data="M34,115 C45,106 91,119 105,112 119,105 172,75.004352 188,82.003591"/>
</Grid>

enter image description here

显然移除一次性动画的 RepeatBehavior,并修改值以获得您想要的。干杯。

关于c# - 是否可以为 path.Data 设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36597877/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com