How to confirm which properties are associated with XAML?

I have a "MainModelView" that implements INotifyPropertyChangedand has a property that provides ObservableCollection<T>, called ExposedCollection. In our MainPage.xaml, we have a ListBox whose ItemsSource object must be bound to MainModelView.ExposedCollection.

MainModelView makes a REST call to populate ExposedCollectionin the background. When WebClientexecuted, its ASyncCallback calls NotifyPropertyCHanged, which checks to see if the PropertyChanged event is null, and if it does not raise it. Pretty simple stuff

The problem is that the ListBox is never bound to an ExposedCollection. I set a breakpoint on our zero check for NotifyPropertyChanged, and there are never listeners on PropertyChanged.

I tried to create an instance of MainViewModel in PhoneApplicationPage.Resources, in, PhoneApplicationPage.DataContextand PhoneApplicationFrame.DataContextin App.xaml. In all cases, the PropertyChanged event is still zero. 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>  
+3
source share
2 answers

You should check the output window in Visual Studio to see if there are any binding errors when starting your application.

+1
source

I'm not sure if this matters, but have you tried implementing ExposedCollectiondependency as a property? If you do, can this eliminate the need for an interface INotifyPropertyChangedand help with list binding? Crazy things worked for me ...

+1
source

All Articles