C # WPF child window (about window)

I have a C # / WPF application that I am developing ... I have btn called About , which should open a new window containing information about the application or something that I put to it.

When I click on btn, a new window opens (about), when I click again when a new window opens (about), another opens, how can I prevent this, I also want the application to be turned off when the About window opens and turns on when closing the About window, like most applications, when they click on it.

+5
source share
2 answers

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

Code example:

 // Instantiate window AboutWindow aboutWindow = new AboutWindow(); // Show window modally // NOTE: Returns only when window is closed Nullable<bool> dialogResult = aboutWindow.ShowDialog(); 
+5
source

Just use the ShowDialog () method instead of Show ()

 AboutWindow aboutWindow = new AboutWindow(); aboutWindow.ShowDialog(); 
+1
source

Source: https://habr.com/ru/post/887106/


All Articles