We have a strange problem with WPF XamGrid .
It works in following way:
- In the constructor of UserControl containing our XamGrid is set the ItemsSource:
DataGrid.ItemsSource = list_of_rows;
- There is a refreshing function, which updates list_of_rows . At the end we use pair of functions:
DataGrid.Rows.Clear();
DataGrid.InvalidateData();
to refresh XamGrid.
The trouble is, that sometimes there is a „dummy“ row among other rows as if rows was not cleared „sufficiently“. The funny thing is, that there is a difference between rows, and data source (please see the attachement – dumped content of rows and datasource at the same time – difference is at row with index 76).
Is there any solution, or another (better) way to refresh XamGrid?
Thank you in advance.
Hello,
Thank you for your post. I have been looking into it and I can say that the XamGrid's InvalidateData method is used to refresh the sortings, groups etc. Could you please be more specific what kinfd of refresh you want for your XamGrid?
Looking forward for your reply.
thank you for your answer. I do not want to refresh the design of XamGrid, just its data. When I developed the application, I tought, that the simple refresh of data source (XamGrid.ItemsSource - which in our case has type List<...>) would be enough, but unfortunately was not (did not work properly, this is the reason, why I used InvalidateData()) . Data source of the whole application is an MSSQL database, data (which app has to display) are added quite often into it, and sometimes they are some rows with "old data" (which were displayed e.g. 3 hours ago).
I am just looking for the best way to refresh data in XamGrid. Maybe data source "unbounding" would help? I mean e.g.:
DataGrid.ItemsSource = null;
// creating the object list_of_rows (type is List<...>)
Thank you for your help.