Search code examples
uwptelerik-griduwp-xaml

Scrolling RadDataGrid with hidden columns throws error


My DataGrid has hidden columns. If I try to horizontally scroll to the end of the table before I "unhide" the columns, I get the following error. Could someone please help?

{Windows.UI.Xaml.UnhandledExceptionEventArgs} Exception: {System.IndexOutOfRangeException: Index was outside the bounds of the array. at Telerik.UI.Xaml.Controls.Grid.IndexStorage.ValueForIndex(Int32 index, Boolean approximate) at Telerik.UI.Xaml.Controls.Grid.CellsController1.UpdateSlotWidth(Int32 cellSlot, Double cellWidth) at Telerik.UI.Xaml.Controls.Grid.Model.GridModel.Telerik.UI.Xaml.Controls.Grid.ITable.GenerateCellsForColumn(Int32 columnSlot, Double largestColumnElementWidth, IItemInfoNode columnDecorator) at Telerik.UI.Xaml.Controls.Grid.NodePool2.GenerateCellsForLine(Int32 slot, Double largestLength, T lastElement) at Telerik.UI.Xaml.Controls.Grid.NodePool2.GenerateContainer(IList1 itemInfos) at Telerik.UI.Xaml.Controls.Grid.NodePool2.MeasureForward(MeasureContext& context) at Telerik.UI.Xaml.Controls.Grid.NodePool2.MeasureHorizontally(RadSize availableSize, Double offset, Int32 frozenElementsCount) at Telerik.UI.Xaml.Controls.Grid.NodePool2.OnMeasure(RadSize availableSize, Double offset, Int32 frozenElementsCount, Double verticalBufferScale) at Telerik.UI.Xaml.Controls.Grid.Model.GridModel.MeasureHeaderRow(RadSize newAvailableSize) at Telerik.UI.Xaml.Controls.Grid.RadDataGrid.OnHeaderRowMeasure(RadSize newAvailableSize) at Telerik.UI.Xaml.Controls.Grid.Primitives.DataGridColumnHeaderPanel.Measure() at Telerik.UI.Xaml.Controls.Grid.RadDataGrid.SetHorizontalOffset(Double physicalOffset, Boolean updateUI, Boolean updateScrollViewer) at Telerik.UI.Xaml.Controls.Grid.RadDataGrid.UpdateScrollOffsetOnRendering() at Telerik.UI.Xaml.Controls.Grid.RadDataGrid.CompositionTarget_Rendering(Object sender, Object e)} Handled: false Message: "System.IndexOutOfRangeException: Index was outside the bounds of the array.\r\n at Telerik.UI.Xaml.Controls.Grid.IndexStorage.ValueForIndex(Int32 index, Boolean approximate)\r\n at Telerik.UI.Xaml.Controls.Grid.CellsController1.UpdateSlotWidth(Int32 cellSlot, Double cellWidth)\r\n at Telerik.UI.Xaml.Controls.Grid.Model.GridModel.Telerik.UI.Xaml.Controls.Grid.ITable.GenerateCellsForColumn(Int32 columnSlot, Double largestColumnElementWidth, IItemInfoNode columnDecorator)\r\n at Telerik.UI.Xaml.Controls.Grid." Native View: To inspect the native object, enable native code debugging. ? e {Windows.UI.Xaml.UnhandledExceptionEventArgs} Exception: {System.IndexOutOfRangeException: Index was outside the bounds of the array. at Telerik.UI.Xaml.Controls.Grid.IndexStorage.ValueForIndex(Int32 index, Boolean approximate) at Telerik.UI.Xaml.Controls.Grid.CellsController1.UpdateSlotWidth(Int32 cellSlot, Double cellWidth) at Telerik.UI.Xaml.Controls.Grid.Model.GridModel.Telerik.UI.Xaml.Controls.Grid.ITable.GenerateCellsForColumn(Int32 columnSlot, Double largestColumnElementWidth, IItemInfoNode columnDecorator) at Telerik.UI.Xaml.Controls.Grid.NodePool2.GenerateCellsForLine(Int32 slot, Double largestLength, T lastElement) at Telerik.UI.Xaml.Controls.Grid.NodePool2.GenerateContainer(IList1 itemInfos) at Telerik.UI.Xaml.Controls.Grid.NodePool2.MeasureForward(MeasureContext& context) at Telerik.UI.Xaml.Controls.Grid.NodePool2.MeasureHorizontally(RadSize availableSize, Double offset, Int32 frozenElementsCount) at Telerik.UI.Xaml.Controls.Grid.NodePool2.OnMeasure(RadSize availableSize, Double offset, Int32 frozenElementsCount, Double verticalBufferScale) at Telerik.UI.Xaml.Controls.Grid.Model.GridModel.MeasureHeaderRow(RadSize newAvailableSize) at Telerik.UI.Xaml.Controls.Grid.RadDataGrid.OnHeaderRowMeasure(RadSize newAvailableSize) at Telerik.UI.Xaml.Controls.Grid.Primitives.DataGridColumnHeaderPanel.Measure() at Telerik.UI.Xaml.Controls.Grid.RadDataGrid.SetHorizontalOffset(Double physicalOffset, Boolean updateUI, Boolean updateScrollViewer) at Telerik.UI.Xaml.Controls.Grid.RadDataGrid.UpdateScrollOffsetOnRendering() at Telerik.UI.Xaml.Controls.Grid.RadDataGrid.CompositionTarget_Rendering(Object sender, Object e)} Handled: false Message: "System.IndexOutOfRangeException: Index was outside the bounds of the array.\r\n at Telerik.UI.Xaml.Controls.Grid.IndexStorage.ValueForIndex(Int32 index, Boolean approximate)\r\n at Telerik.UI.Xaml.Controls.Grid.CellsController1.UpdateSlotWidth(Int32 cellSlot, Double cellWidth)\r\n at Telerik.UI.Xaml.Controls.Grid.Model.GridModel.Telerik.UI.Xaml.Controls.Grid.ITable.GenerateCellsForColumn(Int32 columnSlot, Double largestColumnElementWidth, IItemInfoNode columnDecorator)\r\n at Telerik.UI.Xaml.Controls.Grid."

And here is the XAML:

<tg:RadDataGrid>
<tg:RadDataGrid.Columns>
    <tg:DataGridTextColumn PropertyName="Number"
                                     Header="Number"
                                     SizeMode="Auto"/>
    <tg:DataGridTextColumn PropertyName="BaseText"
                                     Header="Base Text"
                                     SizeMode="Fixed"
                                     Width="300"
                           IsVisible="{Binding IsChecked,                      ElementName=ShowBaseCheckbox,Mode=TwoWay}">
    </tg:DataGridTextColumn>

</tg:RadDataGrid.Columns>
</tg:RadDataGrid>

Solution

  • Telerik says this issue has been addressed in the latest update. I have downloaded it from NuGet and it does seem to have fixed the problem.