まず、両方の形状が同じ座標系を使用することを確認して欲しいものです。両方とも、Path
として描画することができます。一方はEllipseGeometry
、他方はPathGeometry
と共通のCanvas親で描画できます。キャンバスの左上隅が座標原点を定義します。
<Canvas Margin="100">
<Path Stroke="Black">
<Path.Data>
<EllipseGeometry RadiusX="50" RadiusY="50"/>
</Path.Data>
</Path>
<Path Stroke="LightBlue" StrokeThickness="5">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="0,-50">
<ArcSegment Point="42.5,-26.2" Size="50,50"
IsLargeArc="False" SweepDirection="Clockwise"/>
</PathFigure>
<PathGeometry.Transform>
<RotateTransform Angle="15"/>
</PathGeometry.Transform>
</PathGeometry>
</Path.Data>
</Path>
</Canvas>
今ArcSegmentのPoint
とRotateTransformのAngle
ニーズに応じて調整します。
更新:
<Path Stroke="LightBlue" StrokeThickness="5">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="0,-50">
<ArcSegment Point="42.5,-26.2" Size="50,50"
IsLargeArc="False" SweepDirection="Clockwise"/>
</PathFigure>
<PathGeometry.Transform>
<RotateTransform x:Name="transform"/>
</PathGeometry.Transform>
</PathGeometry>
</Path.Data>
<Path.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="transform"
Storyboard.TargetProperty="Angle"
To="360" Duration="0:0:2" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Path.Triggers>
</Path>
または明示的にRotateTransformを命名することなく、::
<Path Stroke="LightBlue" StrokeThickness="5">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="0,-50">
<ArcSegment Point="42.5,-26.2" Size="50,50"
IsLargeArc="False" SweepDirection="Clockwise"/>
</PathFigure>
<PathGeometry.Transform>
<RotateTransform/>
</PathGeometry.Transform>
</PathGeometry>
</Path.Data>
<Path.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Data.Transform.Angle"
To="360" Duration="0:0:2" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Path.Triggers>
</Path>
おかげであなたは常にこのような円弧セグメントを回転させるアニメーションを追加することができます!私はストーリーボードを追加しようとしています。 – Jandy
あなたが実際に円弧セグメントをアニメーション化したいのか、おそらくちょうどそのコードを後ろのコードから何らかの価値に設定したいのかどうかは、あなたの質問からは明らかではありませんでした。永遠に動くアニメーションがほしいのですか? – Clemens
はい、私はコードbehind.thanksからそれを行う方法を知っています! 。私は、XAMLからストーリーボードを追加しようとする<ストーリーボード期間= "0:0:1" RepeatBehavior = "永遠" オートリバース= "真の"> \t \t \t \t \t \t \t \t 。問題があります。 –
Jandy