1
Answer

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

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)

0
Photo of Rajeesh Menoth
NA 24.7k 629.6k 8y
Hi,
 
var is an implicit type and string is an explicit type but these declarations are functionaly equivalent
 
Reference :
 
http://stackoverflow.com/questions/16790143/what-is-the-difference-between-var-and-string-in-c
Accepted