출처 : http://www.microsoft.com/showcase/en/US/details/58757441-f910-425d-b1eb-da09faf4628c#


'.NET Framework > .NET Framework 4.0' 카테고리의 다른 글

윈도우7(WPF4)에서 멀티터치 구현하기  (0) 2010/07/15
Posted by 데모집팀 황리건
시간은 TimeSpan으로, 색상은 Color 클래스의 정적 메소드로 생성할 수 있다.

TimeSpan.FromSeconds(2);
Color.FromArgb(255, 255, 0, 0);


저작자 표시 비영리 동일 조건 변경 허락
Posted by 데모집팀 황리건

http://msdn.microsoft.com/en-us/library/cc189019(VS.96).aspx

  • Create a DoubleAnimation

  • Create a Storyboard

  • Begin the Storyboard in response to an even

  • private void Create_And_Run_Animation(object sender, EventArgs e)
    {
        // Create a red rectangle that will be the target
        // of the animation.
        Rectangle myRectangle = new Rectangle();
        myRectangle.Width = 200;
        myRectangle.Height = 200;
        Color myColor = Color.FromArgb(255, 255, 0, 0);
        SolidColorBrush myBrush = new SolidColorBrush();
        myBrush.Color = myColor;
        myRectangle.Fill = myBrush;

        // Add the rectangle to the tree.
        LayoutRoot.Children.Add(myRectangle);

        // Create a duration of 2 seconds.
        Duration duration = new Duration(TimeSpan.FromSeconds(2));

        // Create two DoubleAnimations and set their properties.
        DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
        DoubleAnimation myDoubleAnimation2 = new DoubleAnimation();

        myDoubleAnimation1.Duration = duration;
        myDoubleAnimation2.Duration = duration;

        Storyboard sb = new Storyboard();
        sb.Duration = duration;

        sb.Children.Add(myDoubleAnimation1);
        sb.Children.Add(myDoubleAnimation2);

        Storyboard.SetTarget(myDoubleAnimation1, myRectangle);
        Storyboard.SetTarget(myDoubleAnimation2, myRectangle);

        // Set the attached properties of Canvas.Left and Canvas.Top
        // to be the target properties of the two respective DoubleAnimations.
        Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(Canvas.Left)"));
        Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(Canvas.Top)"));

        myDoubleAnimation1.To = 200;
        myDoubleAnimation2.To = 200;

        // Make the Storyboard a resource.
        LayoutRoot.Resources.Add("unique_id", sb);

        // Begin the animation.
        sb.Begin();
    }
    저작자 표시 비영리 동일 조건 변경 허락
    Posted by 데모집팀 황리건