How to resolve the issue of not being able to close a new window in WPF?
If you are unable to close a new window opened in a WPF application, you can try the following solution:
- The opening in a building that allows light to enter and provides a view of the outside.
- Display in the taskbar
- correct
<Window ...
ShowInTaskbar="True">
...
</Window>
- “I need to close the window.”
- Proprietor
- Proprietor
NewWindow newWindow = new NewWindow();
newWindow.Owner = Application.Current.MainWindow;
newWindow.Show();
- Shut it.
- Press the button
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
- Close the current application.
- Press
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
Following the above steps should resolve the issue of being unable to close a new window opened in a WPF application.