How to cast a System.Windows.Controls.SelectedItemCollection? How to cast a System.Windows.Controls.SelectedItemCollection? wpf wpf

How to cast a System.Windows.Controls.SelectedItemCollection?


Right, got it sorted. I kept trying to cast it like

IList<PuzzleViewModel> collection = (IList<PuzzleViewModel>)param;

Which told me it couldn't convert from SelectedItemCollection to IList...

This is in fact what you need to do.

System.Collections.IList items = (System.Collections.IList)param;var collection = items.Cast<PuzzleViewModel>();


from reflector : -

[Category("Appearance"), Bindable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]public IList SelectedItems{    get    {        return base.SelectedItemsImpl;    }}

Selected Items of ListView is an IList, id like to see the calling method.


Check The Type:System.Collections.Generic.IList<(Of <(ListViewDataItem>)>)