WPF Mousedown => No MouseLeave Event

Viewed 5073

I'm building a Windows Presentation Foundation control with Microsoft Blend.

When I leave my control by pressing the left-mouse-button, the MouseLeave-Event is not raised. Why not?

4 Answers

Old question but I came across the same problem with a Button (MouseLeave does not fire while MouseDown because MouseDown Captures the Mouse...)

This is how I solved it anyway:

element.GotMouseCapture += element_MouseCaptured;

static void element_MouseCaptured(object sender, MouseEventArgs e)
{
    FrameworkElement element = (FrameworkElement)sender;
    element.ReleaseMouseCapture();
}

Hope that helps someone looking for a quick fix :P

Related