How To Sort a GridView Column When a Header Is Clicked?

How do I sort a GridView column When a header Is clicked?

  • I am following instructions from this MSDN article: http://msdn.microsoft.com/en-us/library/ms745786.aspx But, I'm binding Entity Framework objects to the ListView. I get a runtime NotSupportedException "Specified method is not supported" when the Sort() method fails to execute this line: dataView.SortDescriptions.Clear(); How do I need to adapt this example for Entity Framework?

  • Answer:

    Look at http://tomlev2.wordpress.com/2009/08/04/wpf-automatically-sort-a-gridview-continued/ post. It's code written by Thomas Levesque for an attached property that enables the sorting of a GridView by it's column headers. Really well done. If it does not fit your needs, you can look on how he implemented its solution.

Zack Peterson at Stack Overflow Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.