title: Silverlight 4 : Resize Dynamic Rectangles Using Thumb
body: <p>XAML</p>
  
  <pre><code>&lt;Canvas x:Name="cvsBurstImage" MouseLeftButtonDown="cvsBurstImage_MouseLeftButtonDown" Style="{StaticResource BurstCanvasStyle}"&gt;
     &lt;Viewbox x:Name="vbBurstImage" Style="{StaticResource ViewboxCanvasStyle}"&gt;
              &lt;Image x:Name="imgBurstImage" Source="../Assets/Images/default_burst_image.png" ImageFailed="imgBurstImage_ImageFailed"/&gt;
     &lt;/Viewbox&gt;                                   
  &lt;/Canvas&gt;
  </code></pre>
  
  <p>I am facing a strange problem where i need to draw rectangles on a canvas and make them resizable as well as as moveable (place them anywhere in canvas).</p>
  
  <p>I have achieved this via mouse events of canvas;</p>
  
  <ol>
  <li>private void Canvas_MouseLeftButtonDown(object sender,MouseButtonEventArgs e) {} </li>
  <li>private void Canvas_MouseMove(object sender, MouseEventArgs e) {}</li>
  <li>private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) {}</li>
  </ol>
  
  <p>Explanation;
  On MouseLeftButtonDown, i start capturing mouse cordinates and continue doing so with mouse move (make height and width with these cordinates), on MouseLeftButtonUp i stop listening to mouse and draw these cordinates as Rectangle on canvas and add this rectangle to canvas as child element. I also add 3 mouse events to this rectangle;</p>
  
  <ol>
  <li>private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)</li>
  <li>private void Rectangle_MouseMove(object sender, MouseEventArgs e)</li>
  <li>private void Rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)</li>
  </ol>
  
  <p>These events i use to identify a given rectangle (Rectangle_MouseLeftButtonDown) and move this rectangle to mouse cordinates (Rectangle_MouseMove) and stop listening at (Rectangle_MouseLeftButtonUp).</p>
  
  <p>Now, i have to add resize feature in this Rectangle. I wish to achieve this using Thumb, but i am unable to achieve this.</p>
  
  <p>can someone please help me out with this.
  Thanks in advance.</p>