System.InvalidCastException:“无法将类型为“System.Windows.Controls.SelectedItemCollection”的对象强制转换为类型“Aaa[]”。”
wpf获取ListBox的选中项,SelectionMode="Extended",可以选中多个,直接用 Aaa[] selects = (Aaa[])this.lb_id.SelectedItems 报错,可用写法:
Aaa[] selects = this.lb_id.SelectedItems.Cast<Aaa>().ToArray();