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

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Change The Font Size Of Visual Studio Solution Explorer