Skip to content

Commit 1a67c89

Browse files
committed
Fix component initialization issue
1 parent 57dccce commit 1a67c89

12 files changed

+48
-0
lines changed

Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ public partial class WelcomePage1
1414

1515
protected override void OnNavigatedTo(NavigationEventArgs e)
1616
{
17+
// If the navigation is not triggered by button click, view model will be null again
1718
if (_viewModel == null)
1819
{
1920
Settings = Ioc.Default.GetRequiredService<Settings>();
2021
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
22+
}
23+
if (!IsInitialized)
24+
{
2125
InitializeComponent();
2226
}
2327
// Sometimes the navigation is not triggered by button click,

Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ public partial class WelcomePage2
1616

1717
protected override void OnNavigatedTo(NavigationEventArgs e)
1818
{
19+
// If the navigation is not triggered by button click, view model will be null again
1920
if (_viewModel == null)
2021
{
2122
Settings = Ioc.Default.GetRequiredService<Settings>();
2223
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
24+
}
25+
if (!IsInitialized)
26+
{
2327
InitializeComponent();
2428
}
2529
// Sometimes the navigation is not triggered by button click,

Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ public partial class WelcomePage3
1212

1313
protected override void OnNavigatedTo(NavigationEventArgs e)
1414
{
15+
// If the navigation is not triggered by button click, view model will be null again
1516
if (_viewModel == null)
1617
{
1718
Settings = Ioc.Default.GetRequiredService<Settings>();
1819
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
20+
}
21+
if (!IsInitialized)
22+
{
1923
InitializeComponent();
2024
}
2125
// Sometimes the navigation is not triggered by button click,

Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ public partial class WelcomePage4
1212

1313
protected override void OnNavigatedTo(NavigationEventArgs e)
1414
{
15+
// If the navigation is not triggered by button click, view model will be null again
1516
if (_viewModel == null)
1617
{
1718
Settings = Ioc.Default.GetRequiredService<Settings>();
1819
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
20+
}
21+
if (!IsInitialized)
22+
{
1923
InitializeComponent();
2024
}
2125
// Sometimes the navigation is not triggered by button click,

Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ public partial class WelcomePage5
1515

1616
protected override void OnNavigatedTo(NavigationEventArgs e)
1717
{
18+
// If the navigation is not triggered by button click, view model will be null again
1819
if (_viewModel == null)
1920
{
2021
Settings = Ioc.Default.GetRequiredService<Settings>();
2122
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
23+
}
24+
if (!IsInitialized)
25+
{
2226
InitializeComponent();
2327
}
2428
// Sometimes the navigation is not triggered by button click,

Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ public partial class SettingsPaneAbout
1212

1313
protected override void OnNavigatedTo(NavigationEventArgs e)
1414
{
15+
// If the navigation is not triggered by button click, view model will be null again
1516
if (_viewModel == null)
1617
{
1718
_viewModel = Ioc.Default.GetRequiredService<SettingsPaneAboutViewModel>();
1819
_settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();
1920
DataContext = _viewModel;
21+
}
22+
if (!IsInitialized)
23+
{
2024
InitializeComponent();
2125
}
2226
// Sometimes the navigation is not triggered by button click,

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ public partial class SettingsPaneGeneral
1212

1313
protected override void OnNavigatedTo(NavigationEventArgs e)
1414
{
15+
// If the navigation is not triggered by button click, view model will be null again
1516
if (_viewModel == null)
1617
{
1718
_viewModel = Ioc.Default.GetRequiredService<SettingsPaneGeneralViewModel>();
1819
_settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();
1920
DataContext = _viewModel;
21+
}
22+
if (!IsInitialized)
23+
{
2024
InitializeComponent();
2125
}
2226
// Sometimes the navigation is not triggered by button click,

Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ public partial class SettingsPaneHotkey
1212

1313
protected override void OnNavigatedTo(NavigationEventArgs e)
1414
{
15+
// If the navigation is not triggered by button click, view model will be null again
1516
if (_viewModel == null)
1617
{
1718
_viewModel = Ioc.Default.GetRequiredService<SettingsPaneHotkeyViewModel>();
1819
_settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();
1920
DataContext = _viewModel;
21+
}
22+
if (!IsInitialized)
23+
{
2024
InitializeComponent();
2125
}
2226
// Sometimes the navigation is not triggered by button click,

Flow.Launcher/SettingPages/Views/SettingsPanePluginStore.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ public partial class SettingsPanePluginStore
1515

1616
protected override void OnNavigatedTo(NavigationEventArgs e)
1717
{
18+
// If the navigation is not triggered by button click, view model will be null again
1819
if (_viewModel == null)
1920
{
2021
_viewModel = Ioc.Default.GetRequiredService<SettingsPanePluginStoreViewModel>();
2122
_settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();
2223
DataContext = _viewModel;
24+
}
25+
if (!IsInitialized)
26+
{
2327
InitializeComponent();
2428
}
2529
_viewModel.PropertyChanged += ViewModel_PropertyChanged;

Flow.Launcher/SettingPages/Views/SettingsPanePlugins.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ public partial class SettingsPanePlugins
1515

1616
protected override void OnNavigatedTo(NavigationEventArgs e)
1717
{
18+
// If the navigation is not triggered by button click, view model will be null again
1819
if (_viewModel == null)
1920
{
2021
_viewModel = Ioc.Default.GetRequiredService<SettingsPanePluginsViewModel>();
2122
_settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();
2223
DataContext = _viewModel;
24+
}
25+
if (!IsInitialized)
26+
{
2327
InitializeComponent();
2428
}
2529
_viewModel.PropertyChanged += ViewModel_PropertyChanged;

0 commit comments

Comments
 (0)