我们经常收到 DataGrid 的此异常,我们正在尝试重现它,但我们无法找到此问题的原因。
StackTrace 是这样的:
System.Windows.Controls.ItemCollection.GetItemAt(Int32 index) System.Windows.Controls.VirtualizedCellInfoCollection.Contains(DataGridCell cell) System.Windows.Controls.DataGridCell.PrepareCell(Object item, DataGridRow ownerRow, Int32 index) 系统。 Windows.Controls.DataGridCell.PrepareCell(Object item, ItemsControl cellsPresenter, DataGridRow ownerRow) en System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item) en System.Windows.Controls.ItemContainerGenerator .OnItemReplaced(Object oldItem, Object newItem, Int32 index) en System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args) en System.Windows.Controls.ItemContainerGenerator.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType,对象发送者,EventArgs e) zh System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList 列表) zh System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args) zh System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke( Object sender, NotifyCollectionChangedEventArgs e) en System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) en System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e) en System.Windows .WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list) en System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args) en System.Windows.Data.CollectionView。OnCollectionChanged(NotifyCollectionChangedEventArgs args) en System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32adjustedOldIndex, Int32adjustedNewIndex) en System.Windows.Controls.MultipleCopiesCollection.set_CopiedItem(Object value) en System.Windows.Controls.DataGridRow.NotifyPropertyChanged( DependencyObject d, String propertyName, DependencyPropertyChangedEventArgs e, DataGridNotificationTarget 目标) en System.Windows.Controls.DataGridRow.NotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e, DataGridNotificationTarget 目标) en System.Windows.Controls.DataGridRow.OnNotifyRowPropertyChanged(DependencyObject d, enDependencyPropertyChangedEventArgs e) System.Windows.DependencyObject。OnPropertyChanged(DependencyPropertyChangedEventArgs e) en System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) en System.Windows.Controls.DataGridRow.OnPropertyChanged(DependencyPropertyChangedEventArgs e) en System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) en System.Windows.DependencyObject。 UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) en System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType,Boolean isInternal) en System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) en System.Windows.Controls.DataGridRow.PrepareRow(Object item, DataGrid owningDataGrid) en System.Windows.Controls.DataGrid.PrepareContainerForItemOverride(DependencyObject element, Object item) en System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item) en System.Windows.Controls.VirtualizingStackPanel.InsertContainer(Int32 childIndex, UIElement container, Boolean isRecycled) en System。 Windows.Controls.VirtualizingStackPanel.AddContainerFromGenerator(Int32 childIndex, UIElement child, Boolean newRealized) en System.Windows.Controls.VirtualizingStackPanel.GeneratePreviousChild(Int32 childIndex, Size layoutSlotSize) en System.Windows.Controls.VirtualizingStackPanel。EnsureTopCapGenerated(Size layoutSlotSize) en System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint) en System.Windows.Controls.Primitives.DataGridRowsPresenter.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System. Windows.UIElement.Measure(Size availableSize) 和 System.Windows.ContextLayoutManager.UpdateLayout() 和 System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg) System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() 和 System.Windows.Media。 MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) zh System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) zh System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) zh MS.Internal.Threading。ExceptionFilterHelper.TryCatchWhen(对象源,委托方法,对象参数,Int32 numArgs,委托 catchHandler)
或者这个:
在 System.Windows.Controls.ItemCollection.GetItemAt(Int32 index) 在 System.Windows.Controls.VirtualizedCellInfoCollection.Contains(DataGridCell cell) 在 System.Windows.Controls.DataGridCell.PrepareCell(Object item, DataGridRow ownerRow, Int32 index) 在 System .Windows.Controls.DataGridCell.PrepareCell(Object item, ItemsControl cellsPresenter, DataGridRow ownerRow) 在 System.Windows.Controls.Primitives.DataGridCellsPresenter.SyncProperties(Boolean forcePrepareCells) 在 System.Windows.Controls.DataGridRow.SyncProperties(Boolean forcePrepareCells) 在 System System.Windows.Controls.DataGrid.PrepareContainerForItemOverride(DependencyObject 元素,对象项)中的 .Windows.Controls.DataGridRow.PrepareRow(对象项,DataGrid owningDataGrid)。Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost。PrepareItemContainer(DependencyObject 容器,对象项)在 System.Windows.Controls.VirtualizingStackPanel.InsertContainer(Int32 childIndex,UIElement 容器,Boolean isRecycled)在 System.Windows.Controls.VirtualizingStackPanel.AddContainerFromGenerator(Int32 childIndex,UIElement child,Boolean newRealized)在系统.Windows.Controls.VirtualizingStackPanel.GeneratePreviousChild(Int32 childIndex, Size layoutSlotSize) 在 System.Windows.Controls.VirtualizingStackPanel.EnsureTopCapGenerated(Size layoutSlotSize) 在 System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(大小约束) 在 System.Windows.Controls。在 System.Windows.FrameworkElement.MeasureCore(Size availableSize) 在 System.Windows.UIElement.Measure(Size availableSize) 在 System.Windows 的 Primitives.DataGridRowsPresenter.MeasureOverride(大小约束)。ContextLayoutManager.UpdateLayout() 在 System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg) 在 System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() 在 System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) 在 System.Windows.Media。 MediaContext.RenderMessageHandler(Object resizedCompositionTarget) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs,委托 catchHandler)RenderMessageHandlerCore(Object resizedCompositionTarget) 在 System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象源、Delegate 方法、Object args、Int32 numArgs、Delegate catchHandler)RenderMessageHandlerCore(Object resizedCompositionTarget) 在 System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象源、Delegate 方法、Object args、Int32 numArgs、Delegate catchHandler)
我们发现了一些关于 EnableColumnVirtualization(设置为 false)的帖子,但这没有帮助,我们仍然遇到同样的异常。对于如何重现或修复此异常,我们几乎没有想法。有谁知道如何解决这个问题?