This question is locked. New answers and comments are not allowed.
Hi,
When I try to move columns into the front of my grid so they can be "frozen" I sometimes get this error
"Range of Remove(0,8) cannot include items without a corresponding user interface element." Any ideas?
The code used to move a column is
The purpose of the code is to create a hole in the OrderIndex sequence and drop the column into this hole. The field OrderIndex is copied directly into the the GridViewColumn's OrderIndex.
This works fine the first couple of times, but on the 4 or 5th movement the following exception /stack trace occurs:
{System.InvalidOperationException: Range of Remove(0,8) cannot include items without a corresponding user interface element.
at System.Windows.Controls.ItemContainerGenerator.Remove(GeneratorPosition position, Int32 count, Boolean isRecycling)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IRecyclingItemContainerGenerator.Recycle(GeneratorPosition position, Int32 count)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.CleanupRange(IList children, IItemContainerGenerator generator, Int32 startIndex, Int32 count)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.VirtualizeChildren(List`1 blockList, IItemContainerGenerator generator)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.GenerateAndMeasureChildrenForRealizedColumns(Size constraint)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)}
[System.InvalidOperationException]: {System.InvalidOperationException: Range of Remove(0,8) cannot include items without a corresponding user interface element.
at System.Windows.Controls.ItemContainerGenerator.Remove(GeneratorPosition position, Int32 count, Boolean isRecycling)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IRecyclingItemContainerGenerator.Recycle(GeneratorPosition position, Int32 count)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.CleanupRange(IList children, IItemContainerGenerator generator, Int32 startIndex, Int32 count)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.VirtualizeChildren(List`1 blockList, IItemContainerGenerator generator)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.GenerateAndMeasureChildrenForRealizedColumns(Size constraint)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)}
Data: {System.Collections.ListDictionaryInternal}
InnerException: null
Message: "Range of Remove(0,8) cannot include items without a corresponding user interface element."
StackTrace: " at System.Windows.Controls.ItemContainerGenerator.Remove(GeneratorPosition position, Int32 count, Boolean isRecycling)\r\n at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IRecyclingItemContainerGenerator.Recycle(GeneratorPosition position, Int32 count)\r\n at Telerik.Windows.Controls.GridView.GridViewCellsPanel.CleanupRange(IList children, IItemContainerGenerator generator, Int32 startIndex, Int32 count)\r\n at Telerik.Windows.Controls.GridView.GridViewCellsPanel.VirtualizeChildren(List`1 blockList, IItemContainerGenerator generator)\r\n at Telerik.Windows.Controls.GridView.GridViewCellsPanel.GenerateAndMeasureChildrenForRealizedColumns(Size constraint)\r\n at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size constraint)\r\n at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)"
When I try to move columns into the front of my grid so they can be "frozen" I sometimes get this error
"Range of Remove(0,8) cannot include items without a corresponding user interface element." Any ideas?
The code used to move a column is
public void SetOrderIndex(MyDisplayColumn DispCol, int NewOrderIndex) { try { int NextOrderIndex = 0; foreach (MyDisplayColumn dc in this.Where(s => s != DispCol).OrderBy(s => s.OrderIndex)) { if (NextOrderIndex == NewOrderIndex) { NextOrderIndex++; } dc.OrderIndex = NextOrderIndex++; } DispCol.OrderIndex = NewOrderIndex; } catch (Exception ex) { string Message = ex.Message; // trap the message for later handling throw (ex); // rethrow the exception } }The purpose of the code is to create a hole in the OrderIndex sequence and drop the column into this hole. The field OrderIndex is copied directly into the the GridViewColumn's OrderIndex.
This works fine the first couple of times, but on the 4 or 5th movement the following exception /stack trace occurs:
{System.InvalidOperationException: Range of Remove(0,8) cannot include items without a corresponding user interface element.
at System.Windows.Controls.ItemContainerGenerator.Remove(GeneratorPosition position, Int32 count, Boolean isRecycling)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IRecyclingItemContainerGenerator.Recycle(GeneratorPosition position, Int32 count)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.CleanupRange(IList children, IItemContainerGenerator generator, Int32 startIndex, Int32 count)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.VirtualizeChildren(List`1 blockList, IItemContainerGenerator generator)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.GenerateAndMeasureChildrenForRealizedColumns(Size constraint)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)}
[System.InvalidOperationException]: {System.InvalidOperationException: Range of Remove(0,8) cannot include items without a corresponding user interface element.
at System.Windows.Controls.ItemContainerGenerator.Remove(GeneratorPosition position, Int32 count, Boolean isRecycling)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IRecyclingItemContainerGenerator.Recycle(GeneratorPosition position, Int32 count)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.CleanupRange(IList children, IItemContainerGenerator generator, Int32 startIndex, Int32 count)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.VirtualizeChildren(List`1 blockList, IItemContainerGenerator generator)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.GenerateAndMeasureChildrenForRealizedColumns(Size constraint)
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)}
Data: {System.Collections.ListDictionaryInternal}
InnerException: null
Message: "Range of Remove(0,8) cannot include items without a corresponding user interface element."
StackTrace: " at System.Windows.Controls.ItemContainerGenerator.Remove(GeneratorPosition position, Int32 count, Boolean isRecycling)\r\n at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IRecyclingItemContainerGenerator.Recycle(GeneratorPosition position, Int32 count)\r\n at Telerik.Windows.Controls.GridView.GridViewCellsPanel.CleanupRange(IList children, IItemContainerGenerator generator, Int32 startIndex, Int32 count)\r\n at Telerik.Windows.Controls.GridView.GridViewCellsPanel.VirtualizeChildren(List`1 blockList, IItemContainerGenerator generator)\r\n at Telerik.Windows.Controls.GridView.GridViewCellsPanel.GenerateAndMeasureChildrenForRealizedColumns(Size constraint)\r\n at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size constraint)\r\n at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)"
