I have an WPF application, when at first start displays window to select language. So, in 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">
in WindowLanguage:
public partial class WindowLanguage : Window
{
bool mainWindowOpened = false;
public WindowLanguage()
{
if (!Settings.Instance.firstStart)
{
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
Close();
}
It works, but unnecessary Window is init.
I think about following way: 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);
}
This second way with changing StartupUri is better or not? Which way is the best for my situation (open WindowLanguage during first start of app)?