Cast Datagrid.SelectedItems Collection To List


Answer :

Make sure to use the System.Linq namespace then :

You should be able to use :

List<Foo> SelectedItemsList = DataGrid.SelectedItems.Cast<Foo>().ToList(); 

or if you're not quite sure what DataGrid.SelectedItems contains :

List<Foo> SelectedItemsList = DataGrid.SelectedItems.OfType<Foo>().ToList() 

Try this:

DataGrid.SelectedItems.OfType<Foo>().ToList() 

Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?