I want that the user can resize a control by draging a resize-grip on the lower right border. With the ResizeGrip there seems to exists the perfect control for
Ok, I got bored last night and wrote a little sample for you using Thumb. You should be able to Copy/Paste/Compile/Run.
But basically, I created a UserControl named DialogReplica, just something that looks like a dialog with a grip, you can see it thrown in the main window.
Here's the xaml for the UserControl (you mostly interested in the Thumb part):
finally, here's the code behind for the UserControl
public partial class DialogReplica : UserControl
{
private Cursor _cursor;
public DialogReplica()
{
InitializeComponent();
}
private void OnResizeThumbDragStarted(object sender, DragStartedEventArgs e)
{
_cursor = Cursor;
Cursor = Cursors.SizeNWSE;
}
private void OnResizeThumbDragCompleted(object sender, DragCompletedEventArgs e)
{
Cursor = _cursor;
}
private void OnResizeThumbDragDelta(object sender, DragDeltaEventArgs e)
{
double yAdjust = sizableContent.Height + e.VerticalChange;
double xAdjust = sizableContent.Width + e.HorizontalChange;
//make sure not to resize to negative width or heigth
xAdjust = (sizableContent.ActualWidth + xAdjust) > sizableContent.MinWidth ? xAdjust : sizableContent.MinWidth;
yAdjust = (sizableContent.ActualHeight + yAdjust) > sizableContent.MinHeight ? yAdjust : sizableContent.MinHeight;
sizableContent.Width = xAdjust;
sizableContent.Height = yAdjust;
}
}