먼저 두 모양이 동일한 좌표 시스템을 사용해야합니다 원하는 것입니다. 두 가지 모두를 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
예, 코드 뒤에서 코드를 수행하는 방법을 알고 있습니다. 감사합니다! . 내가 XAML에서 스토리 보드를 추가하려고 <스토리 보드 기간 = "0 : 0 : 1"RepeatBehavior = "영원히"AutoReverse = "진정한"> \t \t \t \t \t \t \t \t . 문제가 있습니다. –
Jandy