Hi im learning about MVVM and Win8 app development, and Im having trouble with binding an ObservableCollection (located in NoteViewModel.cs) to my MainPage listbox (or listview) through XAML.
public ObservableCollection<Note> NotesList;
The Model is a simple Note.cs class, which holds NoteText, Priority and RemindDate.
What Im doing right now is set the DataContext in the code-behind file of MainPage.xaml.cs to the ObservableCollection.
public MainPage()
{
this.InitializeComponent();
NoteViewModel nvm = new NoteViewModel();
noteListView.DataContext = nvm.NotesList;
}
And in the NoteViewModel Constructor I simply create 2 new Notes which I then add to the Collection.
What I would like to do is set the DataContext in XAML to the NoteViewModel and the ItemsSource to the NotesList. I want to implement a DetailsView to a single note later.
There are lots of tutorial with binding collections to listboxes, but I havent found one which shows the MVVM-correct way to do so.
Any help?