Windows Vista Forums

Rotate Control in C#

  1. #1


    MyWebTV Guest

    Rotate Control in C#

    I like to rotate a image control by using animation and control in coding. I
    am using DoubleAnimation and set from and to for the rotation. I have trouble
    to set DepedencyProperty for the rotation. Is any one show me how to set it
    in C# code ?

    Thanks



      My System SpecsSystem Spec

  2. #2


    Vipin [MVP] Guest

    Re: Rotate Control in C#

    Shouldn't you be using MatrixAnimation?

    --
    Vipin Aravind
    http://www.explorewindows.com


    "MyWebTV" <MyWebTV@discussions.microsoft.com> wrote in message
    news:E3B1D437-F8B7-46FB-82AA-6FE04A310D27@microsoft.com...
    >I like to rotate a image control by using animation and control in coding.
    >I
    > am using DoubleAnimation and set from and to for the rotation. I have
    > trouble
    > to set DepedencyProperty for the rotation. Is any one show me how to set
    > it
    > in C# code ?
    >
    > Thanks




      My System SpecsSystem Spec

  3. #3


    Andrew C Guest

    RE: Rotate Control in C#

    Here is a simple way of doing a rotation animation on an image without using
    matrices.

    Code:
    //Create new image object
    Image myImage = new Image();
    //Create a rotation transform
    RotateTransform rotateTransform = new RotateTransform(0);
    //Apply the transform to the image
    myImage.RenderTransform = rotateTransform;
    //Create a new double animation
    DoubleAnimation doubleAnimation = new DoubleAnimation();
    doubleAnimation.From = 0; //Set From value
    doubleAnimation.To = 180; //Set To Value
    doubleAnimation.Duration = 10; //Time it takes to do the animation
    //After the animation is complete hold the last value
    doubleAnimation.FillBehavior = FillBehavior.HoldEnd;

    //Begin the animation on the rotation animation
    rotateTransform.BeginAnimation(RotateTransform.AngleProperty,
    doubleAnimation);



    In your case I don't think you need to resort to using MatrixAnimations.

    Hope this helps,
    Andrew C


    "MyWebTV" wrote:

    > I like to rotate a image control by using animation and control in coding. I
    > am using DoubleAnimation and set from and to for the rotation. I have trouble
    > to set DepedencyProperty for the rotation. Is any one show me how to set it
    > in C# code ?
    >
    > Thanks


      My System SpecsSystem Spec

Rotate Control in C#

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to rotate my display. michaelj7 Graphic cards 5 28 Oct 2009
how to rotate less than 90 degrees? theorbo Live Photo Gallery 2 20 Apr 2008
Add a button that will allow you to rotate a fax you are veiwing William Vista print fax & scan 0 29 Mar 2007
Does Rotate also mean skew? Konstantinos Pantos Avalon 7 21 Jul 2006
Image Rotate with C# Thomas Mueller Avalon 2 04 Apr 2006