Fully initialize context menus when they change (#38998)

If we don't slow-initialize the whole menu when it changes, then we won't see that there's secondary (& more) commands.  

Tested this with the extension from [waaverecords/CmdPal.Ext.Spotify#4](https://github.com/waaverecords/CmdPal.Ext.Spotify/pull/4)

Closes #38959 


Also seemingly closes #38347 - seems that needed additional bumping of the `EmptyContent`'s
This commit is contained in:
Mike Griese
2025-04-23 10:54:01 -05:00
committed by GitHub
parent b0e7473760
commit 54e058e82d
3 changed files with 10 additions and 2 deletions

View File

@@ -29,6 +29,8 @@ public partial class CommandBarViewModel : ObservableObject,
field = value; field = value;
SetSelectedItem(value); SetSelectedItem(value);
OnPropertyChanged(nameof(SelectedItem));
} }
} }
@@ -115,6 +117,10 @@ public partial class CommandBarViewModel : ObservableObject,
{ {
ShouldShowContextMenu = false; ShouldShowContextMenu = false;
} }
OnPropertyChanged(nameof(HasSecondaryCommand));
OnPropertyChanged(nameof(SecondaryCommand));
OnPropertyChanged(nameof(ShouldShowContextMenu));
} }
// InvokeItemCommand is what this will be in Xaml due to source generator // InvokeItemCommand is what this will be in Xaml due to source generator

View File

@@ -167,7 +167,7 @@ public partial class ContentPageViewModel : PageViewModel, ICommandBarContext
Commands.ForEach(contextItem => Commands.ForEach(contextItem =>
{ {
contextItem.InitializeProperties(); contextItem.SlowInitializeProperties();
}); });
} }
else else

View File

@@ -436,7 +436,7 @@ public partial class ListViewModel : PageViewModel, IDisposable
break; break;
case nameof(EmptyContent): case nameof(EmptyContent):
EmptyContent = new(new(model.EmptyContent), PageContext); EmptyContent = new(new(model.EmptyContent), PageContext);
EmptyContent.InitializeProperties(); EmptyContent.SlowInitializeProperties();
break; break;
case nameof(IsLoading): case nameof(IsLoading):
UpdateEmptyContent(); UpdateEmptyContent();
@@ -454,6 +454,8 @@ public partial class ListViewModel : PageViewModel, IDisposable
return; return;
} }
UpdateProperty(nameof(EmptyContent));
DoOnUiThread( DoOnUiThread(
() => () =>
{ {