title: Analog Clock, Rotate Hands C# WPF
body: <p>I am working on a WPF project, trying to create an analog clock. I have an image of a clock (without the hands) and have set it as a background. I also have images of two hands of clock, which I want to rotate keeping one end fixed (like it happens in a clock). How can I rotate the image keeping its one end fixed in C#.NET (WPF)? What I have tried is the following code:</p>
  
  <pre><code>namespace AnalogWatch
  {
  /// &lt;summary&gt;
  /// Interaction logic for MainWindow.xaml
  /// &lt;/summary&gt;
  public partial class MainWindow : Window
  {
  
      DispatcherTimer dispatcherTimer;
      private int degrees = 0;
      public MainWindow()
      {
          InitializeComponent();
          dispatcherTimer = new DispatcherTimer();
          dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
          dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
      }
  
      private void dispatcherTimer_Tick(object sender, EventArgs e)
      {
          degrees += 5;
          if (degrees &gt; 360)
          {
              degrees = 0;
          }
          RotateTransform transform = new RotateTransform(degrees,StickImg.Width/2,StickImg.Height/2);
          //StickImg.RenderTransformOrigin = new System.Windows.Point(0, 0);
          StickImg.RenderTransform = transform;
      }
  
      private void Window_ContentRendered_1(object sender, EventArgs e)
      {
          dispatcherTimer.Start();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>It is rotating the image but not keeping its one end fixed. What is the problem here ?</p>
  
  <p>XAML is:</p>
  
  <pre><code>&lt;Window x:Class="AnalogWatch.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="MainWindow" Height="350" Width="525" ContentRendered="Window_ContentRendered_1"&gt;
  &lt;Grid&gt;
      &lt;Image x:Name="StickImg" HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="100" Margin="207,70,0,0" Source="stick.png"/&gt;
  &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>