【发布时间】:2013-09-09 08:57:07
【问题描述】:
我的视图模型中有一个ICollectionView,绑定到视图中的DataGrid。当我执行添加/删除操作时。我得到了这个例外。
我无法更改CollectionView。谁能告诉我这个异常的原因,以便我可以找到解决方案。
例外:
“添加的项目未出现在给定索引处”
堆栈跟踪:
在 System.Windows.Data.ListCollectionView.AdjustBefore(NotifyCollectionChangedAction 操作,对象项,Int32 索引) 在 System.Windows.Data.ListCollectionView.CommitNew() 在 System.Windows.Controls.DataGrid.CommitRowItem() 在 System.Windows.Controls.DataGrid.OnExecutedCommitEdit(ExecutedRoutedEventArgs e) 在 System.Windows.Input.CommandBinding.OnExecuted(对象发送者,ExecutedRoutedEventArgs e) 在 System.Windows.Input.CommandManager.ExecuteCommandBinding(对象发送者,ExecutedRoutedEventArgs e,CommandBinding commandBinding) 在 System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings,对象发送者,RoutedEventArgs e,ICommand 命令,布尔执行) 在 System.Windows.Input.CommandManager.FindCommandBinding(对象发送者,RoutedEventArgs e,ICommand 命令,布尔执行) 在 System.Windows.Input.CommandManager.OnExecuted(对象发送者,ExecutedRoutedEventArgs e) 在 System.Windows.RoutedEventArgs.InvokeHandler(委托处理程序,对象目标) 在 System.Windows.EventRoute.InvokeHandlersImpl(对象源,RoutedEventArgs 参数,布尔 reRaised) 在 System.Windows.UIElement.RaiseEventImpl(DependencyObject 发件人,RoutedEventArgs 参数) 在 System.Windows.Input.RoutedCommand.ExecuteImpl(对象参数,IInputElement 目标,布尔用户启动) 在 System.Windows.Controls.DataGrid.EndEdit(RoutedCommand 命令,DataGridCell cellContainer,DataGridEditingUnit 编辑单元,布尔 exitEditMode) 在 System.Windows.Controls.DataGrid.OnCurrentCellChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
谢谢
【问题讨论】:
-
你得到什么异常?好像你在途中丢失了一些东西。
-
“添加的项目没有出现在给定的索引处”是我得到的例外。