0

我在 WPF C# 中有一个应用程序,除了它的目的之外,我自定义了关闭和最小化按钮。问题是,当我最小化时,一切都很好,我在所有其他应用程序中循环,但是,当我想回到应用程序时,我在任务栏中单击窗口,然后弹出窗口......但是当它弹出,窗口在整个屏幕上追逐鼠标指针......

我实现的代码是最简单的......

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

    }

你能给我一些方向吗?

谢谢

4

2 回答 2

0

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

于 2010-01-11T19:05:17.040 回答
0

有可能您当时以某种方式捕获了鼠标,并且最小化状态正在阻止 WPF 的正常释放发生。如果您的控件名为“最小化”,请尝试添加:

private void Minimize_LeftMouseDown(object sender, MouseButtonEventArgs e)
{
    // Make sure we're not capturing the mouse anymore
    Mouse.Capture(null);
    this.WindowState = WindowState.Minimized;
}
于 2009-10-07T16:01:37.810 回答