I have a xamdatagrid to which I have binded some Business Objects through a observablecollection.
I then select group by certain column for example : status (consider there are 3 status Accepted, Rejected & completed) and the intial view looks like this.
+ Accepted (7)
+ Rejected (3)
+ Completed (4)
Now if I select a record under any of the groups and change its status to some other valid status. For example I took one completed record and changed its status to "Rejected" . Once the Business object status is changed I replace the BusinessObject in the Observable collection with the new Business object with the changed status.
Result is The BO record is getting updated i.e. I can see that the record's status in the grid is changed to "Rejected".
However the regrouping doesn't happen, Ideally this record should move to the Rejected set of records and count should get accordingly.
Is there anything wrong with the approach? Or how can I acheive this?
Thanks in Advance,
Sashi.
a got this message on stacktrace at Infragistics.Collections.SparseArray.GetItem(Int32 index, ICreateItemCallback createItemCallback) in e:\Work\2\165\Sources\RELEASE\XAML\2010.2\Source\CommonFiles\SparseArray.cs:line 1321
Hello Alex,I have the same scenario in my application, but in my case I change several records at the same time on my ObservableCollection, then when I call the e.Record.RefreshSortPosition I got the following exception "Index was outside the bounds of the array". If I change just one record at time, it works fine.Regards,Anderson
Thanks Alex.
I didn't try the first option. the second scenario worked for me perfectlty.
-Sashi.
Hello Sashi,
There are two things that you might want to consider in this scenario:
1. You do not need to remove the object and add another one. The WPF Framework can do this automatically, but you have to implement the INotifyPropertyChanged interface on your underlying class. This way, changes to any property will be picked up automatically.
2. You can use the InitializeRecord event for the second part. Each record exposes a RefreshSortPosition(...) method (e.Record.RefreshPosition(); )that you can use to get it to the correct position due to change in criteria/value.