■ SplineDoubleKeyFrame 엘리먼트를 사용하는 방법을 보여준다.
▶ 예제 코드 (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 |
<Canvas> <Canvas.Resources> <Storyboard x:Name="storyboard"> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="translateTransform" Storyboard.TargetProperty="X" Duration="0:0:15"> <SplineDoubleKeyFrame KeyTime="0:0:7" Value="500" KeySpline="0.0 1.0 1.0 0.0" /> <SplineDoubleKeyFrame KeyTime="0:0:10" Value="200" KeySpline="0.0 0.0 1.0 0.0" /> <SplineDoubleKeyFrame KeyTime="0:0:15" Value="350" KeySpline="0.25 0.5 0.75 1" /> </DoubleAnimationUsingKeyFrames> </Storyboard> </Canvas.Resources> <Rectangle Width="50" Height="50" Fill="Blue" MouseLeftButtonDown="rectangle_MouseLeftButtonDown"> <Rectangle.RenderTransform> <TranslateTransform x:Name="translateTransform" X="0" Y="0" /> </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 sender, MouseEventArgs e) { this.storyboard.Begin(); } #endregion |