Reputation: 15
I create button command method to open another window in wpf,c#
This is my method
private void fn_cancel(object obj)
{
var windows = Application.Current.Windows;
foreach (Window item in windows)
{
if (item.Name == "passwordReset")
item.Close();
}
loginwindow objlog = new loginwindow();
objlog.Show();
}
in this method "passwordReset" window will close and after that loginwindow doesn't open! The problem in
loginwindow objlog = new loginwindow();
objlog.Show();
Upvotes: 0
Views: 142
Reputation: 4824
It means that you call Close()
for current window where code is executed. If that is the main window, this terminates the application before the new window is shown.
Try open new window before closing the current.
private void fn_cancel(object obj)
{
loginwindow objlog = new loginwindow();
objlog.Show();
this.Close();
}
Upvotes: 1