繁体   English   中英

重现异常:指定的参数超出有效值范围。 参数名称:索引

[英]Reproduce exception: Specified argument was out of the range of valid values. Parameter name: index

我们经常为DataGrid遇到此异常,并且正在尝试重现它,但是我们找不到导致此问题的原因。

StackTrace可能是这样的:


System.Windows.Controls.ItemCollection.GetItemAt(Int32索引)zh-CN System.Windows.Controls.VirtualizedCellInfoCollection.Contains(DataGridCell单元格)zh-CN System.Windows.Controls.DataGridCell.PrepareCell(对象项,DataGridRow ownerRow,Int32索引)zh_cn系统。 Windows.Controls.DataGridCell.PrepareCell(Object item,ItemsControl cellsPresenter,DataGridRow ownerRow)zh-CN System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject容器,Object项)zh_cn System.Windows.Controls.ItemContainerGenerator .OnItemReplaced(Object oldItem,Object newItem,Int32索引)zh-cn System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender,NotifyCollectionChangedEventArgs args)zh-CN System.Windows.Controls.ItemContainerGenerator.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType,Object sender,EventArgs e)System.Windows.WeakEventManager.DeliverEventToList(对象发送者,EventArgs args,ListenerList列表)zh_cn System.Wind ows.WeakEventManager.DeliverEvent(Object sender,EventArgs args)zh_cn System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender,NotifyCollectionChangedEventArgs e)zh_cn System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)zh_cn System.Windows.Controls。 ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(类型managerType,对象发送者,EventArgs e)zh-CN System.Windows.WeakEventManager.DeliverEventToList(对象发送者,EventArgs args,ListenerList列表)zh-CN System.Windows.WeakEventManager.DeliverEvent(对象发送者,EventArgs args)System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) zh_cn System.Windows.Controls.DataGridRow。 NotifyPropertyChanged(DependencyObject d,字符串propertyName,DependencyPropertyChangedEventArgs e,DataGridNotificationTarget目标)zh-CN System.Windows.Controls.DataGridRow.NotifyPropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e,DataGridNotificationTarget目标) )zh_cn System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs) )zh_cn System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex,DependencyProperty dp,PropertyMetadata元数据,EffectiveValueEntry oldEntry,EffectiveValueEntry&newEntry,布尔值coerceWithDefe rredReference,布尔值coerceWithCurrentValue,OperationType operationType)zh-cn System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp,对象值,PropertyMetadata元数据,布尔值coerceWithDeferredReference,布尔值coerceWithCurrentValue,OperationType operationType,布尔值isInternal)en.System.Windows.DependencyObject。 Object值)System.Windows.Controls.DataGridRow.PrepareRow(对象项目,DataGrid owningDataGrid)System.Windows.Controls.DataGrid.PrepareContainerForItemOverride(DependencyObject元素,Object项目)System.Windows.Controls.ItemsControl.MS.Internal。 Controls.IGeneratorHost.PrepareItemContainer(DependencyObject容器,对象项)zh-CN System.Windows.Controls.VirtualizingStackPanel.InsertContainer(Int32 childIndex,UIElement容器,Boolean isRecycled)zh-CN System.Windows.Controls.VirtualizingStackPanel.AddContainerFromGenerator(Int32 childIndex,UIElement子级,Boolean新实现的)System.Windows.C ontrols.VirtualizingStackPanel.GeneratePreviousChild(Int32 childIndex,Size layoutSlotSize)zh-CN System.Windows.Controls.VirtualizingStackPanel.EnsureTopCapGenerated(Size布局SlotSize)zh-CN System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size约束)zh-CN System.Windows.Controls.Primitives.DataGridRowsPresenter .MeasureOverride(大小约束)zh-CN System.Windows.FrameworkElement.MeasureCore(大小availableSize)zh-CN System.Windows.UIElement.Measure(大小availableSize)zh-CN System.Windows.ContextLayoutManager.UpdateLayout()zh-CN System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)zh_cn System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()zh-CN System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)zh-CN System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)zh-CN System.Windows.Threading.ExceptionWrapper .InternalRealCall(Delegate回调,Object args,Int32 numArgs)zh-CN MS.Internal.Threading.Exc eptionFilterHelper.TryCatchWhen(对象源,委托方法,对象args,Int32 numArgs,委托catchHandler)


或者这个:


在System.Windows.Controls.VirtualizedCellInfoCollection.Contains(DataGridCell单元)在System.Windows.Controls.DataGridCell.PrepareCell(对象项,DataGridRow ownerRow,Int32索引)在System.Windows.Controls.ItemCollection.GetItemAt(Int32索引) System.Windows.Controls.Primitives.DataGridCellsPresenter.SyncProperties(Boolean forcePrepareCells)(System.Windows.Controls.DataGridRow.SyncProperties(Boolean forcePrepareCells))上的.Windows.Controls.DataGridCell.PrepareCell(Object item,ItemsControl cellsPresenter,DataGridRow ownerRow) System.Windows.Controls.DataGrid.PrepareContainerForItemOverride(DependencyObject element,Object item)处的System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer处的.Windows.Controls.DataGridRow.PrepareRow(对象项,DataGrid owningDataGrid) (DependencyObject容器,Object项)位于System.Windows.Controls.VirtualizingStackPanel.InsertContainer(Int32 childIndex,UIElement容器,布尔值isRe 在System.Windows.Controls.VirtualizingStackPanel.AddContainerFromGenerator(Int32 childIndex,UIElement child,Boolean新实现)处System.Windows.Controls.VirtualizingStackPanel.AddContainerFromGenerator(Int32 childIndex,Size layoutSlotSize)在System.Windows.Controls.VirtualizingStackPanel.EnsureTopCapGenerated( System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(大小约束)在System.Windows.Controls.Primitives.DataGridRowsPresenter.MeasureOverride(大小约束)在System.Windows.FrameworkElement.MeasureCore(大小可用)在System.Windows。在System.Windows.Media.MediaContext处,System.Windows.Context.LayoutLayout.System.Windows.Context.Manager.UpdateLayoutCallback(Object arg)在System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()处的UIElement.Measure(Size availableSize)。 System.Windows.Media.MediaContext.RenderMessageHandler(Object re)上的RenderMessageHandlerCore(Object resizedCompositionTarget) (System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate回调,Object args,Int32 numArgs)at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source,Delegate method,Object args,Int32 numArgs,Delegate catchHandler)


我们发现了一些有关EnableColumnVirtualization的帖子(设置为false),但这无济于事,我们仍然遇到相同的异常。 关于如何重现或修复此异常,我们几乎没有想法。 是否有人对如何解决此问题有想法?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM