diff --git a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs index 3199e81b7..16252086e 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs @@ -9,24 +9,19 @@ namespace Flow.Launcher.Resources.Pages { public partial class WelcomePage1 { - public Settings Settings { get; private set; } - private WelcomeViewModel _viewModel; + public Settings Settings { get; } = Ioc.Default.GetRequiredService(); + private readonly WelcomeViewModel _viewModel = Ioc.Default.GetRequiredService(); protected override void OnNavigatedTo(NavigationEventArgs e) { - // If the navigation is not triggered by button click, view model will be null again - if (_viewModel == null) - { - Settings = Ioc.Default.GetRequiredService(); - _viewModel = Ioc.Default.GetRequiredService(); - } + // Sometimes the navigation is not triggered by button click, + // so we need to reset the page number + _viewModel.PageNum = 1; + if (!IsInitialized) { InitializeComponent(); } - // Sometimes the navigation is not triggered by button click, - // so we need to reset the page number - _viewModel.PageNum = 1; base.OnNavigatedTo(e); } diff --git a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs index 1eef9fc8c..37767f128 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs @@ -11,24 +11,19 @@ namespace Flow.Launcher.Resources.Pages { public partial class WelcomePage2 { - public Settings Settings { get; private set; } - private WelcomeViewModel _viewModel; + public Settings Settings { get; } = Ioc.Default.GetRequiredService(); + private readonly WelcomeViewModel _viewModel = Ioc.Default.GetRequiredService(); protected override void OnNavigatedTo(NavigationEventArgs e) { - // If the navigation is not triggered by button click, view model will be null again - if (_viewModel == null) - { - Settings = Ioc.Default.GetRequiredService(); - _viewModel = Ioc.Default.GetRequiredService(); - } + // Sometimes the navigation is not triggered by button click, + // so we need to reset the page number + _viewModel.PageNum = 2; + if (!IsInitialized) { InitializeComponent(); } - // Sometimes the navigation is not triggered by button click, - // so we need to reset the page number - _viewModel.PageNum = 2; base.OnNavigatedTo(e); } diff --git a/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs index d27368aa1..4c3184f8c 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs @@ -7,24 +7,19 @@ namespace Flow.Launcher.Resources.Pages { public partial class WelcomePage3 { - public Settings Settings { get; private set; } - private WelcomeViewModel _viewModel; + public Settings Settings { get; } = Ioc.Default.GetRequiredService(); + private readonly WelcomeViewModel _viewModel = Ioc.Default.GetRequiredService(); protected override void OnNavigatedTo(NavigationEventArgs e) { - // If the navigation is not triggered by button click, view model will be null again - if (_viewModel == null) - { - Settings = Ioc.Default.GetRequiredService(); - _viewModel = Ioc.Default.GetRequiredService(); - } + // Sometimes the navigation is not triggered by button click, + // so we need to reset the page number + _viewModel.PageNum = 3; + if (!IsInitialized) { InitializeComponent(); } - // Sometimes the navigation is not triggered by button click, - // so we need to reset the page number - _viewModel.PageNum = 3; base.OnNavigatedTo(e); } } diff --git a/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs index b0999504b..63c9b9a7a 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs @@ -7,24 +7,19 @@ namespace Flow.Launcher.Resources.Pages { public partial class WelcomePage4 { - public Settings Settings { get; private set; } - private WelcomeViewModel _viewModel; + public Settings Settings { get; } = Ioc.Default.GetRequiredService(); + private readonly WelcomeViewModel _viewModel = Ioc.Default.GetRequiredService(); protected override void OnNavigatedTo(NavigationEventArgs e) { - // If the navigation is not triggered by button click, view model will be null again - if (_viewModel == null) - { - Settings = Ioc.Default.GetRequiredService(); - _viewModel = Ioc.Default.GetRequiredService(); - } + // Sometimes the navigation is not triggered by button click, + // so we need to reset the page number + _viewModel.PageNum = 4; + if (!IsInitialized) { InitializeComponent(); } - // Sometimes the navigation is not triggered by button click, - // so we need to reset the page number - _viewModel.PageNum = 4; base.OnNavigatedTo(e); } } diff --git a/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs index 2ece4ce88..8db0a9f7e 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs @@ -10,24 +10,19 @@ namespace Flow.Launcher.Resources.Pages { public partial class WelcomePage5 { - public Settings Settings { get; private set; } - private WelcomeViewModel _viewModel; + public Settings Settings { get; } = Ioc.Default.GetRequiredService(); + private readonly WelcomeViewModel _viewModel = Ioc.Default.GetRequiredService(); protected override void OnNavigatedTo(NavigationEventArgs e) { - // If the navigation is not triggered by button click, view model will be null again - if (_viewModel == null) - { - Settings = Ioc.Default.GetRequiredService(); - _viewModel = Ioc.Default.GetRequiredService(); - } + // Sometimes the navigation is not triggered by button click, + // so we need to reset the page number + _viewModel.PageNum = 5; + if (!IsInitialized) { InitializeComponent(); } - // Sometimes the navigation is not triggered by button click, - // so we need to reset the page number - _viewModel.PageNum = 5; base.OnNavigatedTo(e); }