fix: Ensure ShellModuleVM.MenuContent is created at most once

This commit is contained in:
John Colvin committed 2022-05-25 14:19:03 -04:00
1 parent 47d5b95e13
commit 96ad67b020
1 file changed
+5 -2
@@ -10,6 +10,8 @@ namespace mbts.ui.shell {
readonly IShellModule _module;
readonly IBus _bus;
UIElement _menu_content;
public ShellModuleVM(IShellModule module, IBus bus) {
_module = module;
_bus = bus;
@@ -17,8 +19,9 @@ namespace mbts.ui.shell {
public string Name { get { return _module.name; } }
public ImageSource IconSource { get { return _module.icon; } }
public UIElement MenuContent =>
(_module as IShellModuleViewFactory)?.create_view() ?? new SparkMenu(_module.actions, _bus);
public UIElement MenuContent => _menu_content ??=
(_module as IShellModuleViewFactory)?.create_view() ??
new SparkMenu(_module.actions, _bus);
public void opening() {
(_module as IShellMenu)?.opening();