I have my xamdatagrid filled with collection BindableList<MyObject> where MyObject : INotifyPropertyChanged and properties inside MyObject in setters are calling OnPropertyChanged with proper names, but values in data grid are not refreshed. I tried calling dataGrid.InvalidateVisual() with no result. When I sort any column the values are refreshed but I need sometimes to modify values of items of datagrid on the code side. Should I set any two-way binding in xamdatagrid fields? Fields looks like this: <igDP:Field Name="Limit" Label="Limit" /> and are editable.
..and I event check that PropertyChange event is registered on the item to call the control. But there is no refresh event when I manually (in Immediate Window) call the property.
What is more interesting...
Columns that are modified on the code side are not visible when the window start. If I modify them then and scroll the datagrid I see the updated values, but after it values are not updated.
Hello Lukas,
Thank you for your post. I have been looking into it and I created a sample project for you following your scenario and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
Looking forward for your reply.
Hello Stefan,
thank you for your help. I have found the problem and I am attaching the solution. The problem was instead ObservableCollection<T> I needed BindingList<T>, but I had some issues with this last object when I was adding item to the datagrid, so I have created my own class BindableList<T> : IEnumerable<T>, IBindingList. The problem was that when you create your collection class you need to internally register each item in this collection that implements INotifyPropertyChanged with PropertyChanged event. On this event the BindableList<T> must call it's event: ListChanged - informing that the item has changed. Ufff.... It was not trivial but I have managed. In the project there are also 2-3 more classes that I copied from my original project to preserve the relations between the objects.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.