I've been working on learning MVVM. I know VB.NET a lot better than C#, but most of the resources out there are C#, so I'm trying to polish up my C# while learning MVVM... fun stuff.
I've found a bunch of tutorials out there, including this one: http://www.c-sharpcorner.com/UploadFile/raj1979/simple-mvvm-pattern-in-wpf/
I follow most of it - and I have it working. However, I kind of want to understand the code a little bit better. The view model: UserViewModel.cs has the following code (excerpt):
private ICommand mUpdater;
private ICommand UpdateCommand
if (mUpdater == null)
mUpdater = new Updater();
mUpdater = value;
private class Updater : ICommand
#region ICommand Members
public bool CanExecute(object parameter)
public event EventHandler CanExecuteChanged;
public void Execute(object paramater)
So I understand that first we create a property of type iCommand called mUpdater.
Then we create another property called UpdateCommand. (this is bound in the view)
the get and set properties of UpdateCommand is what is really throwing me:
if mUpdater == null (I'm assuming it's null initially), it creates a new instance of Updater.
What exactly is mUpdater returning? It looks like basically that get and set for UpdateCommand makes it into an instance of Updater with a bool property, an event and a method Execute that is empty.
But what is causing the user information to change when the button linked to UpdateCommand is clicked?
When I look at the UpdateCommand here, it doesn't look like it really should be doing anything.
Sorry if the question seems vague, I just feel like I almost have this, if I can just get my head around this last part.
My entire code is the tutorial in the link above, I didn't re-post it here because it's clearer in the tutorial.
Thanks for your help!!!