Skip to content

Commit 9a5cb99

Browse files
committed
Ensure ViewModel is only created once
1 parent 8d596cb commit 9a5cb99

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

Files/BaseLayout.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
238238
{
239239
//App.CurrentInstance.ViewModel = new ItemViewModel();
240240
//App.CurrentInstance.InteractionOperations = new Interaction();
241-
Page_Loaded(null, null);
241+
//Page_Loaded(null, null);
242242
}
243243
}
244244
}

Files/Controls/Sidebar.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ private void Sidebar_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
3131
{
3232
(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.HomeItems.isEnabled = false;
3333
(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.ShareItems.isEnabled = false;
34+
if(args.InvokedItem == null) { return; }
3435

3536
if ((args.InvokedItemContainer.DataContext as INavigationControlItem).ItemType == NavigationControlItemType.Location)
3637
{

Files/Navigation/UniversalPath.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public string path
1717

1818
set
1919
{
20-
if(value != null)
20+
if(!string.IsNullOrWhiteSpace(value))
2121
{
2222
_path = value;
2323
NotifyPropertyChanged("path");

Files/ProHome.xaml.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public sealed partial class ProHome : Page, IShellPage
2828
{
2929
Frame IShellPage.ContentFrame => ItemDisplayFrame;
3030

31-
Interaction IShellPage.InteractionOperations => new Interaction();
31+
Interaction IShellPage.InteractionOperations => interactionOperation;
3232

33-
ItemViewModel IShellPage.ViewModel => new ItemViewModel();
33+
ItemViewModel IShellPage.ViewModel => viewModel;
3434

3535
BaseLayout IShellPage.ContentPage => GetContentOrNull();
3636

@@ -146,6 +146,8 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
146146
NavParams = eventArgs.Parameter.ToString();
147147
}
148148

149+
private ItemViewModel viewModel = null;
150+
private Interaction interactionOperation = null;
149151

150152
private void Page_Loaded(object sender, RoutedEventArgs e)
151153
{
@@ -155,6 +157,9 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
155157
App.CurrentInstance = this as IShellPage;
156158
}
157159

160+
viewModel = new ItemViewModel();
161+
interactionOperation = new Interaction();
162+
158163
switch (NavParams)
159164
{
160165
case "Start":

0 commit comments

Comments
 (0)