WPF BindingListCollectionView to ListCollectionView for DataTable as ItemsSource
Posted
by Marco
on Stack Overflow
See other posts from Stack Overflow
or by Marco
Published on 2010-05-23T01:15:31Z
Indexed on
2010/05/23
1:20 UTC
Read the original article
Hit count: 1587
Hi everyone,
I want to do custom sorting on a ListView which has a DataTable as ItemsSource:
myListView.ItemsSource = (data as DataTable);
And this are the first lines of my sorting function:
DataView view = (myListView.ItemsSource as DataTable).DefaultView;
ListCollectionView coll = (ListCollectionView)CollectionViewSource.GetDefaultView(view);
The second line throws an execption like:
Unable to cast "System.Windows.Data.BindingListCollectionView" to "System.Windows.Data.ListCollectionView"
Has anyone a solution? Thx 4 answers
© Stack Overflow or respective owner