Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
Observable Collection not sorted when the Header is clicked and table is sorted
posted

Hi,

i have an observable collection of say, 10 items, in my datagrid.  Let's say i have the 5th item in the list clicked.  I have a "previous record" button that when clicked, has a command that sets the previous (in our case, the 4th record) to activeRecord.  however, when I click on a header and it resorts the columns, the observable collection is not updated.  so when I click the button again, it gets the 3rd record from the observable collection and not my newly sorted list.

 

My DataPresenter's DataSource looks like this:

DataSource="{Binding Path=TenItemList, Mode=TwoWay}" 

 

I have tried using the Sorted event and to sort with the CollectionViewSource however, that is not working either.

 

Is there an easy way to update the Observable Collection? or if not, is there a new list I should be getting the index from instead of the ObservableCollection?