Search code examples
c#wpfchildwindow

C# WPF child window (about window)


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.


Solution

  • 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();