2009-05-27 4 views
0

Ich habe ein Problem in Bezug auf StartUp Url in WPF. Ich habe eine LoginView.xaml und MainWindow.xaml. Ich möchte zuerst LoginView öffnen, um automatisch MainWindow zu öffnen.StartUp URL in WPF

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-Fenster geöffnet normalerweise nach, dass nichts passiert, und die Anwendung geschlossen ist.

Ich versuchte einen anderen Ansatz, aber ich habe das gleiche Ergebnis.

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(); 
     } 
    } 

Wer kann mir sagen, wie kann ich das gewünschte Ergebnis zu bekommen? Vielen Dank im Voraus.

Antwort