Hello all. I have created an application (WPF/C#) with several windows that I call with ShowDialog.
All works well unless I try to show two different windows, one after the other using ShowDialog on each. For some reason the second window will not show.
I created a new WPF application to reproduce the issue, leaving the default MainWindow. I added two additional windows. On each I added a single button that sets the DialogResult to true.
In App.cs I added the following....
using System.Windows;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Window1 w1 = new Window1();
bool? result1 = w1.ShowDialog();
if (result1.HasValue)
{
if (result1.Value)
{
string x = "";
}
}
Window2 w2 = new Window2();
bool? result2 = w2.ShowDialog();
if (result2.HasValue)
{
if (result2.Value)
{
string y = "";
}
}
}
}
}
Could anyone clue me into why this line does not show the second window?
bool? result2 = w2.ShowDialog()
Regards,