XAML
<Canvas x:Name="cvsBurstImage" MouseLeftButtonDown="cvsBurstImage_MouseLeftButtonDown" Style="{StaticResource BurstCanvasStyle}">
<Viewbox x:Name="vbBurstImage" Style="{StaticResource ViewboxCanvasStyle}">
<Image x:Name="imgBurstImage" Source="../Assets/Images/default_burst_image.png" ImageFailed="imgBurstImage_ImageFailed"/>
</Viewbox>
</Canvas>
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).
I have achieved this via mouse events of canvas;
- private void Canvas_MouseLeftButtonDown(object sender,MouseButtonEventArgs e) {}
- private void Canvas_MouseMove(object sender, MouseEventArgs e) {}
- private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) {}
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;
- private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- private void Rectangle_MouseMove(object sender, MouseEventArgs e)
- private void Rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
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).
Now, i have to add resize feature in this Rectangle. I wish to achieve this using Thumb, but i am unable to achieve this.
can someone please help me out with this. Thanks in advance.