tags:

views:

164

answers:

2

Hi!

I have an application in WPF C# where other than the purpose of what it's done, I customized the close and minimize buttons. The problem is that when I minimize, all is good, I cycle around all other apps, but, when I want to go back to the application, I click in the window in the taskbar, and the window pops up... But when it pops up, the window pursues the mouse pointer throughout the screen...

The code i've implemented the the simplest it can be...

    private void Minimize_LeftMouseDown(object sender, MouseButtonEventArgs e)
    {
        this.WindowState = WindowState.Minimized;

    }

Can you point me some directions?

Thanks

A: 

It's possible that you've somehow captured the mouse at that point, and the minimize state is preventing WPF's normal release from occurring. If your control is named "Minimize", try adding:

private void Minimize_LeftMouseDown(object sender, MouseButtonEventArgs e)
{
    // Make sure we're not capturing the mouse anymore
    Mouse.Capture(null);
    this.WindowState = WindowState.Minimized;
}
Reed Copsey
A: 

Use the LeftMouseUp event instead of LeftMouseDown. You want to minimize the window when the mouse is released, not when it is pressed down.

jnylen