DataGrid column sort not working with linq itemsource

Feb 17, 2009 at 3:48 AM
I am populating a datagrid with data from linq.  This works great, except clicking on the column header does not sort the column.  The column header shows the sort direction arrow, but the contents are not sorted.  How can I get the sort function to work?  Here is the code I am using to load the datagrid.

Private

 

Sub LoadGrid()

 

 

Dim lang = From p In db.LanguageText Order By p.SpanishText Select p.SpanishText, p.EnglishText

 

spanishGrid.ItemsSource = lang

spanishGrid.Columns(0).Header =

"Spanish"

 

spanishGrid.Columns(0).MinWidth = 100

spanishGrid.Columns(1).Header =

"English"

 

spanishGrid.Columns(1).MinWidth = 100

 

End Sub

 

Coordinator
Feb 17, 2009 at 8:09 PM
Hi John_s,

This is a known issue.  Please see this page for more information: http://www.codeplex.com/wpf/Wiki/View.aspx?title=Data%20Sources&referringTitle=Tips%20%26%20Tricks

Thanks,
Samantha
Feb 17, 2009 at 8:25 PM

Thanks Samantha.  I am not using linq to SQL, I am using linq to an entity.

shared db As New spanishEntities

spanishEntities is my EntityContainer.  Based on the known issues page you referred me to, shouldn't this work?

John

Coordinator
Feb 19, 2009 at 7:40 PM
Hi John,

I believe that LINQ to Entity has the same problem.  Any data source which returns an IBindingList will break our built-in sort.

Thanks,
Samantha
Feb 22, 2009 at 9:03 PM
Edited Feb 22, 2009 at 9:04 PM
Hi,

I have the same problem.

Will it be fixed soon?

Best regards

Toni