Search Chirayu Software Solutions Blog

Tuesday, September 11, 2012

Artificially Rotate a Wheel WPF

Step 1  Dowload this Image.

Step - 2  Add image tag
  <Image Margin="41,30,38,35" Name="image1" Stretch="None"  IsEnabled="True" StretchDirection="Both" Source="/WpfApplication1;component/Images/wheel.png" />
Note:Select our own Source Path
Step - 3 Add the following code in on Window_Loaded

 private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DoubleAnimation da = new DoubleAnimation
                (360, 0, new Duration(TimeSpan.FromSeconds(3)));
            RotateTransform rt = new RotateTransform();
            image1.RenderTransform = rt;
            image1.RenderTransformOrigin = new Point(0.5, 0.5);
            da.RepeatBehavior = RepeatBehavior.Forever;
            rt.BeginAnimation(RotateTransform.AngleProperty, da);
        }
Step - 4 Run and Check the Output
Post a Comment