■ Rectangle 엘리먼트를 사용해 회전 애니메이션을 만드는 방법을 보여준다.
▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<Canvas> <Canvas.Resources> <Storyboard x:Name="storyboard"> <DoubleAnimation Storyboard.TargetName="rotateTransform" Storyboard.TargetProperty="Angle" Duration="0:0:5" From="45" To="405" RepeatBehavior="Forever" /> </Storyboard> </Canvas.Resources> <Rectangle Canvas.Left="50" Canvas.Top="50" Width="100" Height="100" Fill="Gold" Opacity="0.2" /> <Rectangle Canvas.Left="50" Canvas.Top="50" Width="100" Height="100" Fill="Gold" MouseLeftButtonDown="rectangle_MouseLeftButtonDown"> <Rectangle.RenderTransform> <RotateTransform x:Name="rotateTransform" CenterX="50" CenterY="50" Angle="45" /> </Rectangle.RenderTransform> </Rectangle> </Canvas> |
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
using System.Windows.Input; #region 사각형 마우스 왼쪽 버튼 DOWN시 처리하기 - rectangle_MouseLeftButtonDown(sender, e) /// <summary> /// 사각형 마우스 왼쪽 버튼 DOWN시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void rectangle_MouseLeftButtonDown(object pSender, MouseEventArgs e) { this.storyboard.Begin(); } #endregion |