I’ve got a “MainModelView” which implements INotifyPropertyChanged and has a property that exposes an ObservableCollection<T> called ExposedCollection. In our MainPage.xaml, we have a ListBox whose ItemsSource is supposed to be bound to MainModelView.ExposedCollection.
The MainModelView makes a REST call to populate the ExposedCollection in the background. When WebClient is done doing its thing, the ASyncCallback calls NotifyPropertyCHanged which checks if the PropertyChanged event is null, and if not raises it. Pretty basic stuff
Problem is, ListBox never seems to bind to ExposedCollection. I set a breakpoint on our null check for NotifyPropertyChanged, and there are never any listeners on PropertyChanged.
I’ve tried instantiating MainViewModel in PhoneApplicationPage.Resources, in PhoneApplicationPage.DataContext and the PhoneApplicationFrame.DataContext in App.xaml. In all cases the PropertyChanged event is still null. What am I missing here?
<phone:PhoneApplicationPage.DataContext>
<gmvm:MainViewModel x:Name="MainViewModel" />
</phone:PhoneApplicationPage.DataContext>
...
<ListBox x:Name="MyListBox" ItemsSource="{Binding ExposedCollection}" Margin="0,20,-12,0">
.....
</Listbox>
You should check the Output window in Visual Studio to see if there are any binding errors when running your app.