Silverlight data binding from VM issue
I have a SL 3.0 page with a lot of textblock controls laid out. Each textblock is bound to a property of the Account class. The XAML page codebehind (mypage.xaml.cs) has a OnNavigatedTo method in which the VM instance is created and set to the data context like this: this.DataContext = new VM();
In the VM there is a public property of datatype Account and in the ctor of the VM a WCF service method is called asynchronously an开发者_如何学Pythond in the callback method the Account property is set.
With all this, the data is not showing in the XAML view. Any help?
In the absence of details I would guess using the most likely cause for this issue. Your "VM" does not implement INotifyPropertyChanged and/or you are not invoking the PropertyChanged event when the Account property is set.
See my answer to such an issue here for an example implementation.
Thank you very much Anthony...the problem was with INotifyPropertyChanged improperly used. I was actually invoking the PropertyChanged event on individual properties of Account class and not on the (much needed) VM Account property! Once I fixed that it is now working like a charm!!
精彩评论