本文介绍了显示隐藏的WPF窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我做到这一点:

this.Hide();
var window2 = new Window2();
window2.ShowDialog();
this.Show();



作为空白和空白窗口中打开的第一个窗口。

The first window open as a blank and empty window.

什么是错的这个技术

当我这样做:

var window2 = new Window2();
Visibility = Visibility.Collapsed;
window2.ShowDialog();
Visibility = Visibility.Visible;



第一个窗口退出,那么应用程序。

The first window exits then the application.

什么是错的这个技术呢?

What's wrong in this technique too?

推荐答案

您不应该使用隐藏在WPF是有心计的WinForms进行。

You shouldn't be using hide in WPF that is winforms shenanigans.

而不是做

this.visibility = Visibility.Collapsed;    
...    
this.visibility = Visibility.Visible;



另外,我看到上面你对此有何评论这不起作用。不过,我开始了一个新的WPF项目,这样做,建成并运行它。 。它的工作原理

Also I saw your comment above that this doesn't work. However, I started a new WPF project, did this, built and ran it. It works.

请注意,有没有错误。

这篇关于显示隐藏的WPF窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 15:21