0

最初に起動時に言語を選択するウィンドウが表示されるときに、私はWPFアプリケーションを持っています。したがって、App.xaml では次のようになります。

<Application x:Class="MyApp.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="WindowLanguage.xaml">

WindowLanguage で:

public partial class WindowLanguage : Window
{
    bool mainWindowOpened = false;
    public WindowLanguage()
    {
        if (!Settings.Instance.firstStart)
        {
            MainWindow mainWindow = new MainWindow();
            mainWindow.Show();
            Close();
        }

動作しますが、不要なウィンドウが初期化されています。

次の方法について考えます: App.xaml.cs

protected override void OnStartup(StartupEventArgs e)
{
    base.OnStartup(e);
    if (!Settings.Instance.firstStart)
        StartupUri = new Uri("/MyApp;component/MainWindow.xaml", UriKind.Relative);

}

StartupUri を変更するこの 2 番目の方法は、優れているかどうか? 私の状況 (アプリの最初の起動時に WindowLanguage を開く) に最適な方法はどれですか?

4

1 に答える 1