I’m trying to make a button which resizes the window when it is dragged, just like the bottom right corner of a window.
I tried using the .MouseMove and .MouseDown events, but it doesn’t work. Here is an example of my code:
void ButtonResize_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
Point pos = e.GetPosition(Window);
Window.Width += (pos - MousePos_OLD).X;
Window.Height += (pos - MousePos_OLD).Y;
}
MousePos_OLD = e.GetPosition(Window);
}
I also tried using the MouseDown event, and a MouseMove event was taking care of updating the mouse position, but nothing…
So how can I do this in WPF?
There exists a Control for that: a Thumb:
It containes an event events DragDelta which is what you search for.
EDIT:
to customize his visualization you can set him a Style