我一直在努力将这段 WPF 代码转换为 C#。我对 WPF 比较陌生,我真的希望有人可以在这里帮助我:)
<Path Fill="Blue" Margin="15,15,15,15">
<Path.Data>
<EllipseGeometry x:Name="MyAnimatedEllipseGeometry"
Center="10,100" RadiusX="15" RadiusY="15" />
</Path.Data>
<Path.Triggers>
<EventTrigger RoutedEvent="Path.Loaded">
<BeginStoryboard Name="MyBeginStoryboard">
<Storyboard>
<!-- Animates the ellipse along the path. -->
<PointAnimationUsingPath
Storyboard.TargetName="MyAnimatedEllipseGeometry"
Storyboard.TargetProperty="Center"
Duration="0:0:5"
RepeatBehavior="Forever" >
<PointAnimationUsingPath.PathGeometry>
<PathGeometry
Figures="M 10,100 C 35,0 135,0 160,100 135,0 35,0 10,100"
/>
</PointAnimationUsingPath.PathGeometry>
</PointAnimationUsingPath>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Path.Triggers>
</Path>
</Canvas>
在获得 PathGeometry Figures 之前,我似乎相处得很好……如果有人可以向我提供此 WPF 代码的 C# 代码片段,将不胜感激!