C# WPF child window (about window)

蓝咒 提交于 2020-02-23 16:24:31

问题


I have an application on C#/WPF that I`m developing ... I have a btn named About which should open a new window that contains details about the application or whatever I will put in it.

When I click the btn, a new window (about) opens, when I click again, while the new window (about) is opened another one is opened, how can I prevent this from happening, I also want the application to be disabled when the About window is opened and to be enabled when the About window is closed, Like most of the applications when about is clicked.


回答1:


You should use the ShowDialog Method: http://msdn.microsoft.com/en-us/library/system.windows.window.showdialog.aspx

Code Sample:

// Instantiate window
AboutWindow aboutWindow = new AboutWindow();

// Show window modally
// NOTE: Returns only when window is closed
Nullable<bool> dialogResult = aboutWindow.ShowDialog();



回答2:


Just use ShowDialog() method instead of Show()

AboutWindow aboutWindow = new AboutWindow();
aboutWindow.ShowDialog();


来源:https://stackoverflow.com/questions/5851833/c-sharp-wpf-child-window-about-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!