I'm trying to get up to speed on WPF and MVVM and as I have learned that I need to start using the model view view model pattern I've ran into what shoul dbe a basic problem with getting the xamGrid to display the data from the ViewModel. I've recreated my issue in a small basic project that roughly implements MVVM. I cannot get the grid to display anything and I cannot get the binding debugger to hit.
I must be missing something basic but have no idea what it is.
Thank you!
The problem is that you defined People as a field and not a property. e.g.
Hello,
The problem is that "People" property in the ViewModel is not a property. You have defined it as a field. What you need to do is:
public ObservableCollection<Person> People { get; set; }
instead of:
public ObservableCollection<Person> People;
Do this modification and the sample should run correctly.
Thanks for taking a look and offering some input. In the window1.xaml.cs file ( lines 38 & 57) I set the DataContext of the ContentPane to the viewmodel. ( I know code behind but I took the kiss approach).
There is a Title property on my viewmodel that binds just fine (and debugs witht he converter), I'm not apposed to adding DataTemplates but I'm not sure how it would solve my binding issue.
I briefly looked through your sample project, and cannot find where you actually set the DataContext of the Views to your ViewModel. In the MVVM world you could use a DataTemplate to associate a ViewModel with a view.