From 96ad67b0209dcbdf0bd2f47a562f2ff9cedba5d4 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 18 May 2022 11:55:33 -0400 Subject: [PATCH] fix: Ensure ShellModuleVM.MenuContent is created at most once --- src/client/spark/view/Shell/ViewModels/ShellModuleVM.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/spark/view/Shell/ViewModels/ShellModuleVM.cs b/src/client/spark/view/Shell/ViewModels/ShellModuleVM.cs index f40fe770c..dadca17c8 100644 --- a/src/client/spark/view/Shell/ViewModels/ShellModuleVM.cs +++ b/src/client/spark/view/Shell/ViewModels/ShellModuleVM.cs @@ -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();