Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • I have a GridControl/CardView in a UserControl and I'm getting a System.ArgumentOutOfRangeException was unhandled error when I filter the field being grouped to a single entry and I remove a field from the CardView.

                                    The exception occurs in DevExpress.Xpf.Core.Native.RowInfoCollection's Arrange method. Below are some of the values when the exception occurred.

                                              the sortedChildren count is 0
                                              
                                              cardSpace and currentPosition is 0
                                              
                                              item.ElementCount is 0
                                              
                                    The exception occurred on the line

                                              UIElement element = sortedChildren[i];          

                                              public Rect[] Arrange(Size finalSize, IList<UIElement> sortedChildren) {
                                                   int childIndex = 0;
                                                   Rect[] rects = new Rect[sortedChildren.Count];
                                                   double currentHeight = 0;
                                                   SizeHelperBase sizeHelper = panelInfo.SizeHelper;
                                                   RowSeparators.Clear();
                                                   foreach(RowInfo item in info) {
                                                        double cardSpace = CalcCardSpace(item, sizeHelper.GetSecondarySize(finalSize), panelInfo.Alignment, sizeHelper);
                                                        double currentPosition = CalcNearOffset(item, sizeHelper.GetSecondarySize(finalSize), panelInfo.Alignment, panelInfo.SizeHelper);
                                                        for(int i = childIndex; i < childIndex + item.ElementCount; i++) {
                                    *** >>> ***               UIElement element = sortedChildren[i];
                                                             rects[i] = CreateCardRect(cardSpace, currentHeight, currentPosition, element);
                                                             currentPosition += sizeHelper.GetSecondarySize(rects[i].Size);
                                                        }
                                                        childIndex += item.ElementCount;
                                                        currentHeight += sizeHelper.GetDefineSize(item.Size) + panelInfo.SeparatorThickness;
                                                        if(RowSeparators.Count < info.Count - 1)
                                                             RowSeparators.Add(new LineInfo() { Location = sizeHelper.CreatePoint(currentHeight - panelInfo.SeparatorThickness, 0), Length = sizeHelper.GetSecondarySize(finalSize) });
                                                   }
                                                   return rects;
                                              }

                                    System.ArgumentOutOfRangeException was unhandled
                                      Message=Index was out of range. Must be non-negative and less than the size of the collection.
                                    Parameter name: index
                                      Source=mscorlib
                                      ParamName=index
                                      StackTrace:
                                           at System.ThrowHelper.ThrowArgumentOutOfRangeException()
                                           at System.Collections.Generic.List`1.get_Item(Int32 index)
                                           at DevExpress.Xpf.Core.Native.RowInfoCollection.Arrange(Size finalSize, IList`1 sortedChildren)
                                           at DevExpress.Xpf.Core.CardLayoutCalculator.ArrangeElements(Size finalSize, IList`1 sortedChildren)
                                           at DevExpress.Xpf.Core.CardsPanel.ArrangeSortedChildrenOverride(Size finalSize, IList`1 sortedChildren)
                                           at DevExpress.Xpf.Core.OrderPanelBase.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.Control.ArrangeOverride(Size arrangeBounds)
                                           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 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.Control.ArrangeOverride(Size arrangeBounds)
                                           at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
                                           at System.Windows.UIElement.Arrange(Rect finalRect)
                                           at DevExpress.Xpf.Core.DXExpander.LayoutCalculator.ArrangeOverride(Size arrangeSize)
                                           at DevExpress.Xpf.Core.DXExpander.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 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 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, Int32 numArgs)
                                           at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
                                           at System.Windows.Threading.DispatcherOperation.InvokeImpl()
                                           at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
                                           at System.Threading.ExecutionContext.runTryCode(Object userData)
                                           at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
                                           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
                                           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
                                           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
                                           at System.Windows.Threading.DispatcherOperation.Invoke()
                                           at System.Windows.Threading.Dispatcher.ProcessQueue()
                                           at System.Windows.Threading.Dispatcher.WndProcHook(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, Int32 numArgs)
                                           at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
                                           at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
                                           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()
                                           at Acuity.WIP.App.Main() in C:\Development\Acuity\Acuity\Acuity.WIP\obj\x86\Debug\App.g.cs:line 0
                                           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
                                           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
                                           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
                                           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
                                           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
                                           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
                                           at System.Threading.ThreadHelper.ThreadStart()
                                      InnerException:

                                0

                                Correcion the value of item.ElementCount is 1.

                                0

                                Hello Gregory,

                                Thank you for the report. Could you please provide a sample and steps to recreate the issue? This is hard to understand why you encounter this issue based on your code snippet. I am looking forward to hearing from you.

                                Thank you, Marina

                                0

                                In my production project the UserControl has code that builds a DataTemplate on the fly and assigns that to the CardTemplate property. 99% of the time no error is encountered, but if I am grouping by a field and filter that field so only one group exists and then apply a different DataTemplate to CardTemplate, I get the exception originally mentioned.

                                In order to reduce complexity I've created a simple project with a MainWindow.xaml that hosts your GridControl/CardView. I can get the same exception to occur after grouping, filtering and applying a DataTemplate to the CardTemplate property. Of course, the sample is much less complex, but I think this is what you'll need to better diagnose the problem.

                                When the app starts, group by the "Healthcare Organization" field, filter for "Hospital D" and then hit the Set Template button. Exception!

                                The attached zip contains the project and a screen capture video that shows the steps I went through to reproduce and the exception in your code.

                                The weird thing is if I run the app maximized on my screen (1680x1050) the exception doesn't occur.

                                CardList01.zip

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners