Cast Datagrid.SelectedItems collection to List<T>
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()