Frage

Ich habe ein Problem in Bezug auf StartUp URL in WPF. Ich habe ein LoginView.xaml und MainWindow.xaml. Ich möchte zunächst öffnen Loginview danach automatisch geöffnet Mainwindow werden.

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 habe versucht, einen anderen Ansatz, aber ich habe das gleiche Ergebnis bekam.

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.

War es hilfreich?

Lösung

Auch hier fand ich die Lösung für mein Problem selbst :) hier ist die Lösung

http: //www.ageektrapped. com / blog / the-wpf-application-Klasse-Übersicht-and-gotcha /

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top