Hi,
I am using the ObservableCollection as the datasource for the grid.
In a button click i open another window and changing the data. and sending the message to the main window to refresh the grid.
but, setting the data source to null and setting the source again is not refreshing.
How can i refresh the grid to get the updated data?
That doesn't sound right to me.
The fact that it's an ObserveableCollection will inherently caseu the grid to update for CHANGED items, NEW items and REMOVED items. You won't need to refresh the list for CHANGED data. Of course, this all depends on what your definition of changing the data is.
if you need to change out the entire collection and need the grid to refresh, you do as you mentioned, setting the DataSource -> null and then back to the new collection.
One thought: what are the objects in the collection? Are they custom Classes? If so, you need to implement INotifyPropertyChanged so that the grid can see these individual property changes.
What is if the custom classes implement the INotifyPropertyChanged ?
I think that the xamDataGrid has a bug, if it use a ObserveableCollection !!! The values in cells are not updated!!!
What bothers me with the xamlDG is that to get this to work with the WPF grid all you do is call item.refresh. So what the heck is IF xaml grid making this so abstract and difficult?
Hello,
I do not seem to share the same opinion as you. Implementing INotifyPropertyChanged is not difficult at all - pretty straightforward and helpful not only in the XamDataGrid but in any other scenario involving properties.
Implementing this interface and leaving the rest of the work to the wpf framework seems to me much more safer than calling refresh methods and being on the lookout where things might go wrong.
I agree that as wpf developper, implementing INotifyPropertyChanged should not be a problem.
Yet, I do not find a way to force the FieldLayoutInitializing event to rebuild the field layout when the DataSource is changing.
The data are updated but neither do the associated templates.
Olivier
Did you ever find a solution to this problem? I am having the EXACT same problem.
Linda