簡體   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