StartUp URL in WPF
I have a problem with StartUp Url in WPF. I have LoginView.xaml and MainWindow.xaml. First I want to open LoginView after MainWindow automatically opens.
App.xaml
<Application x:Class="XXX.App"
xmlns="....."
Startup="App_Startup"
>
App.xaml.cs
/
// <summary>
/// Called when the application starts.
/// </summary>
private void App_Startup(object sender, StartupEventArgs e)
{
LoginView frmLogin = new LoginView();
bool? resultScreen = frmLogin.ShowDialog();
if (frmLogin.ShowDialog())
{
Uri uri = new Uri("pack:/MainWindow.xaml", UriKind.RelativeOrAbsolute);
Application.Current.StartupUri = uri;
}
else
{
Application.Current.Shutdown();
}
}
LoginView opened normally, nothing happened after that and the application is closed.
I tried a different approach, but I got the same result.
App.xaml
<Application x:Class="XXX.App"
xmlns="....."
Startup="App_Startup"
>
App.xaml.cs
/// <summary>
/// Called when the application starts.
/// </summary>
private void App_Startup(object sender, StartupEventArgs e)
{
LoginView frmLogin = new LoginView();
bool? resultScreen = frmLogin.ShowDialog();
if frmLogin.ShowDialog())
{
MainWindow frmMainWindow = new MainWindow();
frmMainWindow.ShowDialog();
}
else
{
Application.Current.Shutdown();
}
}
Who can tell me how I can achieve the desired result? Thanks in advance.
0
a source to share
1 answer
Again I found a solution to my problem myself :) here is the solution
http://www.ageektrapped.com/blog/the-wpf-application-class-overview-and-gotcha/
+1
a source to share