wpf 给listview的数据源转换为集合
目的是点击某个按钮把一条数据从 itemssource中移除
private void delete_Click_1(object sender, RoutedEventArgs e)
{
DtsInterfaceItemInfo dtsfice= (DtsInterfaceItemInfo)(sender as FrameworkElement).DataContext; 获取点击的那列的按钮获取该列的数据
//(this.listview.ItemsSource as List<DtsInterfaceItemInfo>).Remove(dtsfice); 原
(this.listview.ItemsSource as ObservableCollection<DtsInterfaceItemInfo>).Remove(dtsfice); 改后
}
原来报错,改后正常
ObservableCollection需要引用using System.Collections.ObjectModel;