开发者

After minimizing app, on restore, windows pursues mouse pointer

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


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;
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜