I have a wpf datagrid that I want to sort programatically as if the user had clicked on the header. After some searching I found reference to using this:
datagrid_selected.Items.SortDescriptions(2).Direction = ComponentModel.ListSortDirection.Ascending
Looks like it would work. Intellisense says Direction is a getter and setter, but when I try to assign it to something I get the “Expression is a value and therefor cannot be the target of an assignment” error. By nature as a setter I should be able to assign this to a value, right? Any idea what’s going wrong?
It appears as if SortDescriptions are boxed values.
Instead, try the following.