5

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.

sikas
  • 5,071
  • 27
  • 72
  • 117

2 Answers2

5

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();
brendan
  • 27,495
  • 18
  • 64
  • 106
1

Just use ShowDialog() method instead of Show()

AboutWindow aboutWindow = new AboutWindow();
aboutWindow.ShowDialog();
Sapan Ghafuri
  • 547
  • 3
  • 12