Friday, February 11, 2011

WPF datagrid : how to sort a column programatically ?

Hi,

How do I sort a column programatically ?

I would like to have a function such as

myWPFDataGrid.Columns[0].Sort(..)

MadSeb

  • Use an ICollectionView as your ItemsSource and CollectionViewSource to generate it. You can set the sort descriptions there and it'll sort your items for you.

    karmicpuppet : A link that does this: http://wpf.codeplex.com/Thread/View.aspx?ThreadId=35944
    Abe Heidebrecht : You don't really need to use it as the ItemsSource. By getting the default collection view, WPF will automatically pick up the sorts you add to it.
    From Aren

0 comments:

Post a Comment