窗口关闭时,无法设置“可见性”或调用“显示”,“显示对话”,“关闭”或“隐藏”。在WPF中

时间:2013-08-27 06:05:19

标签: c# wpf windows-server-2003

我正在使用wpf-C#,我正面临一个问题:那就是 - 关闭窗口时,可见性设置为隐藏,e.Cancel设置为true。它在Windows 7中按预期工作。但是当我使用Windows Server 2003 SP2,.Net framework 3.5测试它时,它没有按预期工作。这意味着,它隐藏了用户,但是当我下次尝试显示它时显示错误 - 窗口关闭时无法设置可见性或调用Show,ShowDialog,Close或Hide。它仅在Windows Server 2003中发生。但在Windows 7中,它可以正常工作。

这段代码是这样的:

private void OnClosing( object sender, System.ComponentModel.CancelEventArgs e )
{
    try
    {
        this.Visibility = Visibility.Hidden;
        e.Cancel = true;
        this.ShowInTaskbar = false;
    }
    catch (Exception ex)
    {
        NeMIASMessageBox.ShowInformationMessageBox(ex.Message);
    }
}

0 个答案:

没有答案