title: Silverlight 3 - Rotating a rectangle around an ellipse
body: <p>I have a Silverlight user control that looks like a compass.  I would post the image but i'm a new user and can't post images yet. :(.    </p>
  
  <p>Essentially think of a an outer ellipse and on the inside is an inner ellipse in the center w/ a rectangle serving as the 'hand' of the compass.  I posted the xaml below.</p>
  
  <p>I want to move the compass 'hand' when the left mouse button is down and the mouse is moved.    I thought this would be relatively easy using a RotateTransform but I can't figure it out.</p>
  
  <p>The problems I am running into are</p>
  
  <p>A.  I can't figure out how to set the CenterX,CenterY and Angle properties of my RotationTransform.  I want the hand (the red rectangle) to rotate around the center ellipse (the brown ellipse in the middle).</p>
  
  <p>B.  Is their a way to slow down the rotationtransform?  So if someone is spinning the mouse quickly the hand moves but not as fast as the user is moving the mouse.  Stated another way is their a way to decrease the sensitivity of the mouse movement?</p>
  
  <p>I would post my code but it is pretty sad.  :-).   I don't need an exact solution just  a nudge in the right direction.</p>
  
  <p>Here is the XAML </p>
  
  <pre><code>&lt;Grid Margin="20,20,0,18" HorizontalAlignment="Left" Width="180"&gt;
          &lt;Ellipse x:Name="outerEllipse" Stroke="Black"&gt;
              &lt;Ellipse.Fill&gt;
                  &lt;LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0"&gt;
                      &lt;GradientStop Color="#3FF7F5F5" Offset="0.449"/&gt;
                      &lt;GradientStop Color="#FFF7F1F1" Offset="0.938"/&gt;
                  &lt;/LinearGradientBrush&gt;
              &lt;/Ellipse.Fill&gt;
          &lt;/Ellipse&gt;
          &lt;Ellipse x:Name="innerEllipse" Margin="16,14,16,13" Stroke="Black"&gt;
              &lt;Ellipse.Fill&gt;
                  &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                      &lt;GradientStop Color="#FFD8BABA" Offset="0"/&gt;
                      &lt;GradientStop Color="#FFF7F1F1" Offset="1"/&gt;
                  &lt;/LinearGradientBrush&gt;
              &lt;/Ellipse.Fill&gt;
          &lt;/Ellipse&gt;
          &lt;Ellipse x:Name="knobEllipse" Margin="83,75,82,74" Stroke="Black" Fill="#FFCFB53B"/&gt;
          &lt;TextBlock x:Name="textNorth" Height="17" Margin="83,14,83,0" TextWrapping="Wrap" Text="N" VerticalAlignment="Top" Foreground="#FFCC3131" FontSize="16" FontFamily="Book Antiqua"/&gt;
          &lt;TextBlock x:Name="textNorthEast" Height="21" Margin="0,34,25.666,0" TextWrapping="Wrap" Text="NE" VerticalAlignment="Top" Foreground="#FFCC3131" FontSize="16" FontFamily="Book Antiqua" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto" HorizontalAlignment="Right" Width="30"&gt;
              &lt;TextBlock.RenderTransform&gt;
                  &lt;CompositeTransform Rotation="45"/&gt;
              &lt;/TextBlock.RenderTransform&gt;
          &lt;/TextBlock&gt;
          &lt;TextBlock x:Name="textSouth" Height="17" Margin="86,0,85,13" TextWrapping="Wrap" Text="S" VerticalAlignment="Bottom" Foreground="#FFCC3131" FontSize="16" FontFamily="Book Antiqua"/&gt;
          &lt;TextBlock x:Name="textNorthWest" Height="21" Margin="29,31,0,0" TextWrapping="Wrap" Text="NW" VerticalAlignment="Top" Foreground="#FFCC3131" FontSize="16" FontFamily="Book Antiqua" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto" HorizontalAlignment="Left" Width="30"&gt;
              &lt;TextBlock.RenderTransform&gt;
                  &lt;CompositeTransform Rotation="315"/&gt;
              &lt;/TextBlock.RenderTransform&gt;
          &lt;/TextBlock&gt;
          &lt;TextBlock x:Name="textEast" HorizontalAlignment="Right" Margin="0,75,16,74" TextWrapping="Wrap" Text="E" Width="11" Foreground="#FFCC3131" FontSize="16" FontFamily="Book Antiqua"/&gt;
          &lt;TextBlock x:Name="textWest" HorizontalAlignment="Left" Margin="16,73,0,72" TextWrapping="Wrap" Text="W" Width="20" Foreground="#FFCC3131" FontSize="16" FontFamily="Book Antiqua"/&gt;
          &lt;TextBlock x:Name="textSouthEast" Margin="0,0,33.834,25.333" TextWrapping="Wrap" Text="SE" Foreground="#FFCC3131" FontSize="16" FontFamily="Book Antiqua" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto" HorizontalAlignment="Right" Height="21" VerticalAlignment="Bottom" Width="30"&gt;
              &lt;TextBlock.RenderTransform&gt;
                  &lt;CompositeTransform Rotation="140"/&gt;
              &lt;/TextBlock.RenderTransform&gt;
          &lt;/TextBlock&gt;
          &lt;TextBlock x:Name="textSouthWest" Margin="31.5,0,0,29.5" TextWrapping="Wrap" Text="SW" Foreground="#FFCC3131" FontSize="16" FontFamily="Book Antiqua" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto" HorizontalAlignment="Left" Width="30" Height="21" VerticalAlignment="Bottom"&gt;
              &lt;TextBlock.RenderTransform&gt;
                  &lt;CompositeTransform Rotation="220"/&gt;
              &lt;/TextBlock.RenderTransform&gt;
          &lt;/TextBlock&gt;
          &lt;Rectangle x:Name="rectanglePointer" Height="32" Margin="87,43,86,0" Stroke="Black" VerticalAlignment="Top"&gt;
              &lt;Rectangle.Fill&gt;
                  &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                      &lt;GradientStop Color="#FFF38989" Offset="0"/&gt;
                      &lt;GradientStop Color="#FF914949" Offset="1"/&gt;
                  &lt;/LinearGradientBrush&gt;
              &lt;/Rectangle.Fill&gt;
          &lt;/Rectangle&gt;
  
      &lt;/Grid&gt;
  </code></pre>
  
  <p>Thanks for your help</p>