Skip to content

Commit 0e46c38

Browse files
Merge pull request #101 from thomasclaudiushuber/issue/98
Adjust NuGet readme to include new Command generation code
2 parents 528fd15 + 6876399 commit 0e46c38

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/MvvmGen/readme.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,16 @@ namespace MyWpfApp.ViewModel
195195
{
196196
partial class EmployeeViewModel : global::MvvmGen.ViewModels.ViewModelBase
197197
{
198+
private IDelegateCommand? _saveCommand;
199+
198200
public EmployeeViewModel()
199201
{
200-
this.InitializeCommands();
201202
this.OnInitialize();
202203
}
203204
204205
partial void OnInitialize();
205206
206-
private void InitializeCommands()
207-
{
208-
SaveCommand = new DelegateCommand(_ => Save(), _ => CanSave());
209-
}
210-
211-
public DelegateCommand SaveCommand { get; private set; }
207+
public IDelegateCommand SaveCommand => _saveCommand ??= new DelegateCommand(_ => Save(), _ => CanSave());
212208
213209
public string FirstName { ... }
214210
@@ -276,10 +272,11 @@ namespace MyWpfApp.ViewModel
276272
{
277273
partial class EmployeeViewModel : global::MvvmGen.ViewModels.ViewModelBase
278274
{
275+
private IDelegateCommand? _saveCommand;
276+
279277
public EmployeeViewModel(MvvmGen.Events.IEventAggregator eventAggregator)
280278
{
281279
this.EventAggregator = eventAggregator;
282-
this.InitializeCommands();
283280
this.OnInitialize();
284281
}
285282

0 commit comments

Comments
 (0)