siva nagarjuna

siva nagarjuna

  • NA
  • 26
  • 16.7k

How to change sort order in a listview/gridview in WPF

Aug 29 2016 6:05 AM
How to change sort order in a listview/gridview in WPF with a binding to LINQ (SQL)?
 
I wonder if someone has an example or an answer to why something like this doesn't work with a LINQquery

lv.Items.SortDescriptions.Clear();

SortDescription sd = new SortDescription(sortBy, direction);

lv.Items.SortDescriptions.Add(sd);

lv.Items.Refresh();

lv is bound to a LINQ queryresult

I found examples using other bindingsources and then I replaced those with LINQ (over SQL) and the listview doesn't show sorting. I understand that I can change the LINQ query to get a sorted result and then rebind - but should that really be nessecery ?

Thankful for suggestions


Answers (1)