From 687639974f4ca8e44b68f8563a125d9025d1b802 Mon Sep 17 00:00:00 2001 From: Thomas Claudius Huber Date: Tue, 12 Dec 2023 19:36:27 +0100 Subject: [PATCH] Adjust NuGet readme to include new Command generation code --- src/MvvmGen/readme.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/MvvmGen/readme.md b/src/MvvmGen/readme.md index 9f6f672..c2be9a0 100644 --- a/src/MvvmGen/readme.md +++ b/src/MvvmGen/readme.md @@ -195,20 +195,16 @@ namespace MyWpfApp.ViewModel { partial class EmployeeViewModel : global::MvvmGen.ViewModels.ViewModelBase { + private IDelegateCommand? _saveCommand; + public EmployeeViewModel() { - this.InitializeCommands(); this.OnInitialize(); } partial void OnInitialize(); - private void InitializeCommands() - { - SaveCommand = new DelegateCommand(_ => Save(), _ => CanSave()); - } - - public DelegateCommand SaveCommand { get; private set; } + public IDelegateCommand SaveCommand => _saveCommand ??= new DelegateCommand(_ => Save(), _ => CanSave()); public string FirstName { ... } @@ -276,10 +272,11 @@ namespace MyWpfApp.ViewModel { partial class EmployeeViewModel : global::MvvmGen.ViewModels.ViewModelBase { + private IDelegateCommand? _saveCommand; + public EmployeeViewModel(MvvmGen.Events.IEventAggregator eventAggregator) { this.EventAggregator = eventAggregator; - this.InitializeCommands(); this.OnInitialize(); }