wpf: capturing mouse does not work

Posted by amethyste on Stack Overflow See other posts from Stack Overflow or by amethyste
Published on 2010-01-04T17:48:14Z Indexed on 2010/04/18 10:03 UTC
Read the original article Hit count: 252

Filed under:
|
|

hello

I am developing an kind of outlook calendar application where I need to make the appointment resizable from mouse. My first try with a thumb did not work properly so I tried another way.

What I did is that:

1) on the botton of the appointmennt panel I added a rectangle to figure out the resize zone (the thumb). The appointment panel is put on a grid panel. 2) I intercept down event on the rectangle and send event to this code:

private Point startPoint;
private void OnResizeElementMouseDown(object sender, MouseButtonEventArgs e)
{
    e.Handled = true;
    this.MouseMove += new MouseEventHandler(ResizeEndElement_MouseMove);
    this.MouseLeftButtonUp += new MouseButtonEventHandler(OnResizeElementMouseUp);
    // some code to perform new height computation
    Mouse.Capture(this);
}

where this is the appointment panel that own the thumb.

Decreasing height works well. But increasing is more difficult. If I move the mouse very very slowly it's OK, if I speed it up a little bit it tends to leave out the appointment panel and then all MouseMove event are lost.

I thought Mouse.Capture() was propose to solve this kind of problem, but in fact not.

Does anybody know what is wrong in my code?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about mouse