I have just set up a test project using your code.
With a couple of mods it works for me.
Firstly, you are using
ShowDialog()
, this means that you can no longer access the main form to launch another window without first closing the previous one manually.
So bearing that in mind, this works for me:
private void btnOEP_Click(object sender, RoutedEventArgs e)
{
CloseAllWindows();
ExistingProject objEP = new ExistingProject();
objEP.Show();
}
private void btnCNP_Click(object sender, RoutedEventArgs e)
{
CloseAllWindows();
AddNewProjects objAddNew = new AddNewProjects();
objAddNew.Show();
}
private void CloseAllWindows()
{
for (int intCounter = App.Current.Windows.Count - 1; intCounter > 0; intCounter--)
App.Current.Windows[intCounter].Close();
}