This is a migrated thread and some comments may be shown as answers.

CaptureMouse prevents moving RadWindow

1 Answer 52 Views
Window
This is a migrated thread and some comments may be shown as answers.
Cameron Molyneux
Top achievements
Rank 1
Cameron Molyneux asked on 05 Mar 2012, 11:06 AM
Hi there,

I have been experimenting with having windows maximise when you drag them to the top, like in Windows 7.

However, using this.CaptureMouse(); in the RadWindow stops the window from being able to be moved.

private void RadWindow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    vertPosition = e.GetPosition(null).Y;
    isCaptured = true;
    this.CaptureMouse();
}
private void RadWindow_MouseMove(object sender, MouseEventArgs e)
{
    if (isCaptured)
    {
        vertPosition = e.GetPosition(null).Y;
        this.Top = e.GetPosition(null).Y;
        this.Left = e.GetPosition(null).X;
    }
}
 
private void RadWindow_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    if (isCaptured)
    {
        if (vertPosition < 30.0)
        this.Height = App.Current.Host.Content.ActualHeight;
        this.Width = App.Current.Host.Content.ActualWidth;
    }
    isCaptured = false;
     this.ReleaseMouseCapture();
}
As you can see from the code I tried to handle moving the window myself, however this causes the resize arrow to appear even if I drag from the header or inside the Window.

Is this a bug or is there a correct way to use CaptureMouse?

Thanks

1 Answer, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 08 Mar 2012, 02:49 PM
Hi Cameron,

All this is caused because we are registering to these event and handling them. I am afraid there is no way this can be achieved with the current implementation of the control.
The only idea I can give you (although this is not tested and I am not sure if you are not going to hit a stumbling block along the way) is to track the position of the mouse and when it reaches the specified position to check whether the RadWindow is dragged with its IsDragging property and maximize it.

Hope this information helps.

Greetings,
Konstantina
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Window
Asked by
Cameron Molyneux
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Share this question
or