ArgumentOutOfRangeException when scrolling in DataGrid

Nov 10, 2008 at 2:43 PM
Hi,
I've gotten a ArgumentOutOfRangeException twice now in my application, which displays a quite complex DataGrid (caught in the DispatcherUnhandledException handler in my App class). One time it occurred when maximizing (before maximizing not all columns were visible) the window and once when scrolling sideways (right I think). I had never seen the error before today and I've been playing around with the grid quite a lot before. However, I recently enabled column virtualization so I suspect it is related to that. Since the exception occurs completely outside of my code I think it might be a bug in the DataGrid. Below follows the entire stack trace:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.ThrowHelper.ThrowArgumentOutOfRangeException()
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at System.Collections.Generic.List`1.System.Collections.IList.get_Item(Int32 index)
   at Microsoft.Windows.Controls.DataGridCellsPanel.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ItemsPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at Microsoft.Windows.Controls.DataGridRow.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.VirtualizingStackPanel.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ItemsPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.ScrollContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Page.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.DockPanel.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Page.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Decorator.ArrangeOverride(Size arrangeSize)
   at System.Windows.Documents.AdornerDecorator.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.DockPanel.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Window.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

Regards,
Mattias


Dec 21, 2008 at 12:08 PM
Hi,

i've looked a little bit inside the code and found that  the problem occurs on line 1356 of DataGridCellsPanel (ArrangeChild(children[childIndex] as UIElement, i, arrangeState);) where the children collection has to less items!

So it's obvious that there's somewhere a bug in the Virtualization Code (realizedChildren contains sometimes not all visible Columns)

Please someone who know's the code better than me could look into that?

regards,
Thomas
Coordinator
Dec 23, 2008 at 12:01 AM
Can you post the DataGrid part of your XAML code ? Also can you describe the ItemsSource of your DataGrid ?
Dec 23, 2008 at 7:51 PM
It's a standard DataGrid with Row & Column Virtualization set to true and filled with automatic generated SampleData, it happens when resizing the whole window randomly for a few seconds.
Feb 24, 2009 at 7:45 AM
Edited Feb 24, 2009 at 8:11 AM
I'm getting the same crash.  I haven't quite figured out what is causing it for me.  Mine is inside a wrap panel, and it seems to correlate to changes in width, due to scrolling larger items out of view, but of course not every time.  It is happening pretty frequently though.

Ok, its happening every time my wrap panel reacts to the DataGrid changing its width.  My pseudo layout is like so:

<Window>
<WrapPanel>
(variable number of these border blocks)
<Border>
<Grid>
<Label/>
<Grid>
<Grid>
<Label/>
<DataGrid/>
</Grid>
</Grid>
</Grid>
</Border>
</WrapPanel>
<Window>

My DataGrid looks like this:

        <dg:DataGrid x:Name="tlist"
                     Grid.Row="1"
                     AutoGenerateColumns="False"
                     SelectionUnit="FullRow"
                     IsSynchronizedWithCurrentItem="True"
                     SelectionMode="Extended"
                     RowDetailsVisibilityMode="VisibleWhenSelected"
                     RowBackground="White"
                     AlternatingRowBackground="LightGray"
                     AlternationCount="2"
                     FrozenColumnCount="1" CanUserSortColumns="True">
            <dg:DataGrid.Columns>
              <!-- -->
            </dg:DataGrid.Columns>

            <dg:DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Button Click="Deselect_Click" VerticalAlignment="Center">
                            <Image Source="Images\tiny_x.png" />
                        </Button>
                        <Border Grid.Column="1"  Margin="15,5,5,5" BorderBrush="Gray" BorderThickness="2" CornerRadius="3" Background="White">
                            <ContentControl Content="{Binding Path=.}">
                                <ContentControl.ContentTemplate>
                                    <MultiBinding Converter="{StaticResource EnumTypeKeyResourceConverter}"
                                                  ConverterParameter="{x:Type local:FileType}">
                                        <Binding Path="FileType" />
                                        <Binding ElementName="tlist" />
                                    </MultiBinding>
                                </ContentControl.ContentTemplate>
                            </ContentControl>
                        </Border>
                    </Grid>
                </DataTemplate>
            </dg:DataGrid.RowDetailsTemplate>
        </dg:DataGrid>

The tricky part being the ContentControl, it essentially is a switch statement on an enum in the Row's DataContext, choosing different contents depending on the context.  These contents have different widths.  Switching between them changes the Width of the DataContext.  By convention, all of my datagrids start out wide.  If I switch the last one of them to a narrow data type, the WrapPanel moves it up to the previous row, next to another DataGrid block.  At that point, I get the ArgumentOutOfRangeException on index. 

Feb 24, 2009 at 9:59 AM

I am seeing similar problems, they do however only occur in my applications if the datagrid is nested inside Panels.
Adding the datagrid to the root grid seems to work without any problems.

I see two different kinds of results when failing;
1) The application crashes when resizing
2) The application utilizes 100% cpu indefinitly

I have seen the same problems while loading larger xml files (XmlDataProvider)

When I break while in the infinity loop it keep getting back at the

protected
override Size ArrangeOverride(Size arrangeSize)

Method in DataGridHeaderBorder.cs and the

 

protected

 

override Size MeasureOverride(Size availableSize)

 

 

Method in DataGridRowHeader.cs
 
I don't have the time to dig deeper at the moment, hopefully someone else can.

Regards,
Ewart

Coordinator
Feb 27, 2009 at 2:28 AM
enijburg and matelich,

Could you both send me a small repro app. I will look into this crash.

Thanks.
Feb 27, 2009 at 11:50 AM
I will try to recreate the problem in a smaller app as soon as I have a bit of time on my hands. It is difficult to reproduce through.

Cheers
Apr 7, 2009 at 7:22 PM
Any update on this issue?  I'm getting the error when I minimize my app and then maximize it when I have virtualization turned on.
May 13, 2009 at 3:47 PM

In the DataGrid below, 'ArgumentOutOfRangeException' occurs when i resize the window just a few times.

And  it´s not related to virtualization...

        <toolkit:DataGrid x:Name="QueryDataGrid"
                     Grid.Row="1"
                     AutoGenerateColumns="True"
                     CanUserAddRows="False"
                     CanUserDeleteRows="False"
                     CanUserResizeRows="False"
                     IsReadOnly="True"
                     SelectionUnit="CellOrRowHeader"
                     IsSynchronizedWithCurrentItem="True"
                     HeadersVisibility="All"
                     Background="Transparent"
                     RowHeaderWidth="25"
                     SelectionMode="Extended"
                     RowBackground="White"
                     AlternatingRowBackground="GhostWhite"
                     AlternationCount="2"
                     GridLinesVisibility="Vertical"
                     AutoGeneratingColumn="QueryDataGrid_AutoGeneratingColumn"
                     AutoGeneratedColumns="QueryDataGrid_AutoGeneratedColumns"        
                     MouseDoubleClick="QueryDataGrid_MouseDoubleClick"
                     ScrollViewer.ScrollChanged="QueryDataGrid_ScrollChanged"
                     ContextMenuOpening="QueryDataGrid_ContextMenuOpening">
        </toolkit:DataGrid>

Stack trace:

   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.ThrowHelper.ThrowArgumentOutOfRangeException()
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at System.Collections.Generic.List`1.System.Collections.IList.get_Item(Int32 index)
   at Microsoft.Windows.Controls.DataGridCellsPanel.ArrangeOverride(Size arrangeSize) in D:\dd\WPF_TSV_2\src\wpf\src\ControlsPack\WPFToolkit\DataGrid\Microsoft\Windows\Controls\DataGridCellsPanel.cs:line 1361
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ItemsPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter.ArrangeOverride(Size finalSize) in D:\dd\WPF_TSV_2\src\wpf\src\ControlsPack\WPFToolkit\DataGrid\Microsoft\Windows\Controls\Primitives\DataGridCellsPresenter.cs:line 484
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at Microsoft.Windows.Controls.DataGridRow.ArrangeOverride(Size arrangeBounds) in D:\dd\WPF_TSV_2\src\wpf\src\ControlsPack\WPFToolkit\DataGrid\Microsoft\Windows\Controls\DataGridRow.cs:line 1098
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.VirtualizingStackPanel.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ItemsPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.ScrollContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Decorator.ArrangeOverride(Size arrangeSize)
   at System.Windows.Documents.AdornerDecorator.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Window.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Interop.HwndSource.Process_WM_SIZE(UIElement rootUIElement, IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Interop.HwndSource.LayoutFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()

May 13, 2009 at 3:54 PM

Hi, did you reproduce this error ?

It happens a lot in my apps, if you need help just let me know...

thanks

Feb 15, 2010 at 4:25 PM

Hi,
I have the same problem in my application.
I were wondering whether the problem has been solved in the newer version of WPF toolkit? If so, in which version?  or in .NET 4.0?
Can anyone update me on the current status of this issue?

Thanks.

Coordinator
Feb 17, 2010 at 2:51 AM

pvitor and atsafrir

The callstack above is very generic and hence its difficult to pinpoint the exact issue. Many bugs in DataGrid were fixed and to be released in the newest version of Toolkit.

The DataGrid control is .NET 4.0 also has many bugs fixed. Hope this helps!

 

Thanks.

Apr 14, 2010 at 7:21 AM

datagrid with larger data and now if you scroll horizontally and then vertically generates "index was out..." exception every time.

Oct 14, 2010 at 9:05 PM

We are experiencing this problem.   It still happens in .NET 4.0. 

I consider this bug a show-stopper.  Is Microsoft working on a fix, or at least a work-around?  Is there an expected timeframe? 

In my experience, the crash happens under these circumstances:

1.  I might be wrong, but I think I've only seen the exception when I had the DataGrid's EnableColumnVirtualization set to True (which we need).

2.  I've seen the crash happen with as little as 9 rows of data, but it seems like it happens more consistently if I have significantly more rows.  The bug doesn't require very many columns' worth of data -- in my test I only had 4 columns.  So when I stretch the window, the rightmost column is blank. 

3.  I have the data grid set up to fill the entire window.  Then I run the app, and resize the window, using the mouse.  I grab the window's lower right corner, and just rapidly move the mouse around.  SPEED seems to be key.  I've only seen the crash when I moved the mouse (did the window resize) quickly.

4.  Sometimes, the crash happens if I jiggle the mouse back in forth just a couple of times (hence, I'm concerned about an end user possibly doing this).  Sometimes, I have to jiggle the mouse like that, for 30 seconds maybe, before the crash happens (this is just to let MS tech support know that you might have to try for a while before you get the crash.)

If this bug isn't already being investigated, then what has to happen to make it be investigated?  Do you need me to send you a sample app?  To what email address?   My product is too big to submit, but the bug can also be demonstrated using various little WPF sample apps I've found online.   For example, from "c-sharpcorner dot com" there's a sample app "DataGrid in WPF" by Mahesh Chand.  I just took his  sample app, and tweaked it - I set EnableColumnVirtualization to true, I added a few more rows of data (in WIndow1.xaml.cs), and I altered xaml settings like Width and Height just to make the datagrid fill the window as the window is resized.  Then the resulting app crashes as I described above.

Please advise!

Nov 2, 2010 at 5:48 PM

We have the same problem too in a WPF client running on .NET 4.0. As it is pretty hard to reproduce in our product test environment we are looking for a smaller sample project that we can try on different machines to see if there is something in the environment that affects the behavior.

The C-Sharp Corner sample with modifications didn't cause any errors in our dev systems so we would like to see a complete project that someone has used to trigger the problem.

/Per

Dec 28, 2010 at 11:10 AM

Bug report - hopefully is already somebody working on it...

Mar 22, 2012 at 6:31 PM

Does anyone has an update on this? Do you know if this issue is fixed on .NET 4.5?

Thanks.

Jul 10, 2014 at 11:16 AM
Hi

I have inherited a Silverlight application that is having the same issue in production. I cannot replicate it from my development/QA areas.

Can you advise me how to fix it. Have you fixed this issue? Do we need a Silverlight patch?

The application has been developed with .NET4. Do we need to upgrade to .NET4.5???

Thanks guys