I have a xamDataGrid bound to ObservableCollection. I am using MVVM pattern. New items are added to the ObservableCollection by an event trigger implemented in the underlying VM class.
I am using:
App.Current.Dispatcher.Invoke(new Action(() => { _tradeSummary.Add(item); })); // _tradeSummary is the ObservableCollection
This works fine and I see the new Row added in the xamDataGrid.
However, when existing data items are changed in the ObservableCollection, I just can't get the existing rows in xamDataGrid to update. I tried using the same App.Current.Dispatcher.Invoke() and Notify(), but didn't work.
Please help.
P.S. If I put my data in a DataTable and bind to DataView, the existing data updates fine but then then new data rows don't show in the grid.
Hello Jay, I am glad to know that you were able to achieve the functionality you were looking for.
No thanks - the issue was with me not having Notify event for each individual data class property.
Hello Jay, Thank you for your feedback. If you have any other questions in particular, please let me know.
I made the changes to your project and it still worked fine. I think, I had implemented each property within my collection as Prop {get; set} without the INotifyPropertyChanged trigger within Set. I think, that should be it - will test tomorrow.
Thanks.
Hello Jay, When using an ObservableCollection and implementing the INotifyPropertyChanged for the DataItems inside, the XamDataGrid's respective records should be successfully updated when using either a command or an event handler. The NotifyPropertyChanged method is responsible for notifying the grid when a particular DataItem's property has been changed. It does not affect the entire XamDataGrid, because certain properties might not use the method. Would you please modify the sample from my previous reply, so the issue is reproduced and send it back to me? Having this information will help me further investigate this matter for you. Looking forward to hearing from you.