我的视图模型中有一个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(Object sender, ExecutedRoutedEventArgs e) 在 System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding) 在 System.Windows。 Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute) at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command,Boolean execute) at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated) at System.Windows.Controls.DataGrid.EndEdit(RoutedCommand命令,DataGridCell cellContainer,DataGridEditingUnit editingUnit,布尔 exitEditMode) 在 System.Windows.Controls.DataGrid.OnCurrentCellChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)System.Windows.EventRoute.InvokeHandlersImpl 的 System.Windows.RoutedEventArgs.InvokeHandler(委托处理程序,对象目标)的 OnExecuted(对象发送者,ExecutedRoutedEventArgs e)(对象源,RoutedEventArgs 参数,布尔 reRaised)在 System.Windows.UIElement.RaiseEventImpl( DependencyObject sender, RoutedEventArgs args) at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated) at System.Windows.Controls.DataGrid.EndEdit(RoutedCommand command, DataGridCell cellContainer, DataGridEditingUnit editingUnit, Boolean exitEditMode) at System.Windows.Controls.DataGrid.OnCurrentCellChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)System.Windows.EventRoute.InvokeHandlersImpl 的 System.Windows.RoutedEventArgs.InvokeHandler(委托处理程序,对象目标)的 OnExecuted(对象发送者,ExecutedRoutedEventArgs e)(对象源,RoutedEventArgs 参数,布尔 reRaised)在 System.Windows.UIElement.RaiseEventImpl( DependencyObject sender, RoutedEventArgs args) at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated) at System.Windows.Controls.DataGrid.EndEdit(RoutedCommand command, DataGridCell cellContainer, DataGridEditingUnit editingUnit, Boolean exitEditMode) at System.Windows.Controls.DataGrid.OnCurrentCellChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)对象目标)在 System.Windows.EventRoute.InvokeHandlersImpl(对象源,RoutedEventArgs 参数,布尔 reRaised)在 System.Windows.UIElement.RaiseEventImpl(DependencyObject 发件人,RoutedEventArgs 参数)在 System.Windows.Input.RoutedCommand.ExecuteImpl(对象参数, System.Windows.Controls.DataGrid.OnCurrentCellChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)处 System.Windows.Controls.DataGrid.EndEdit(RoutedCommand 命令,DataGridCell cellContainer,DataGridEditingUnit 编辑单元,布尔 exitEditMode)处的 IInputElement 目标,布尔 userInitiated)对象目标)在 System.Windows.EventRoute.InvokeHandlersImpl(对象源,RoutedEventArgs 参数,布尔 reRaised)在 System.Windows.UIElement.RaiseEventImpl(DependencyObject 发件人,RoutedEventArgs 参数)在 System.Windows.Input.RoutedCommand.ExecuteImpl(对象参数, System.Windows.Controls.DataGrid.OnCurrentCellChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)处 System.Windows.Controls.DataGrid.EndEdit(RoutedCommand 命令,DataGridCell cellContainer,DataGridEditingUnit 编辑单元,布尔 exitEditMode)处的 IInputElement 目标,布尔 userInitiated)System.Windows.Controls.DataGrid.EndEdit(RoutedCommand command, DataGridCell cellContainer, DataGridEditingUnit editingUnit, Boolean exitEditMode) 在 System.Windows.Controls.DataGrid.OnCurrentCellChanged(DependencyObject d, DependencyPropertyChangedEventArgs e )System.Windows.Controls.DataGrid.EndEdit(RoutedCommand command, DataGridCell cellContainer, DataGridEditingUnit editingUnit, Boolean exitEditMode) 在 System.Windows.Controls.DataGrid.OnCurrentCellChanged(DependencyObject d, DependencyPropertyChangedEventArgs e )
谢谢