Im new with WPF, and I,m stuck with a thing that I thought would be easy to solve.
I have a gridView (telerik one), and it’s ItemsSource is an ObservableCollection, it all works fine, I can see in the grid when a data is modified, when something is deleted or added, the grid is refreshed.
My problem is that when the collection is changed, the changed row goes to the last row in the grid, and I need to reorder it, I have tried to add a SortDescriptor to sort the grid when the collection is changed, but nothing happens.
//This update changes function is the one that changes the collection
updateChanges(field, new_value);
//This is the sortDescriptor that is supposed to order the grid
UIGlobal.MainPage.gridAnalog.SortDescriptors.Add(new SortDescriptor()
{
Member = "ColName",
SortDirection = System.ComponentModel.ListSortDirection.Ascending
});
And this is my grid
<telerik:RadGridView>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn UniqueName="ColName" Header="Name" DataMemberBinding="{Binding Key}"/>
<telerik:GirdViewDataColumn Header="Value" DataMemberBinding="{Binding Value}"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
I am tying to order it from the ColName column, but can’t get it.
Hope somebody can help me.
Thanks!
This was the solution I found, may help somebody.
I added a ColumnSortDescriptor to the grid:
And I disabled the property of UserCanSort.