Bug Report T290346
Visible to All Users

GridControl with GroupFooters throws ThrowArgumentOutOfRangeException when its DataContext is reset

created 9 years ago

Hi,

We have an issue with GridControl in version 14.2.6. We have an observablecollection which describes the columns of the grid and after we scroll horizontally in grid, we clear the observablecollection and it crashes with ArgumentOutOfRangeException. In the following lines I put the stacktrace in order to help you to identify the issue.

at System.ThrowHelper.ThrowArgumentOutOfRangeException()
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at DevExpress.Xpf.Grid.GridGroupFooterScrollablePart.OnScrollingMarginChanged()
   at DevExpress.Xpf.Grid.GridScrollablePart.<.cctor>b__5(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
   at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
   at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
   at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
   at MS.Internal.Data.PropertyPathWorker.OnDependencyPropertyChanged(DependencyObject d, DependencyProperty dp, Boolean isASubPropertyChange)
   at MS.Internal.Data.ClrBindingWorker.OnSourceInvalidation(DependencyObject d, DependencyProperty dp, Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.HandlePropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
   at System.Windows.Data.BindingExpressionBase.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
   at System.Windows.Data.BindingExpression.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
   at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyPropertyKey key, Object value)
   at DevExpress.Xpf.Grid.TableView.set_ScrollingHeaderVirtualizationMargin(Thickness value)
   at DevExpress.Xpf.Grid.TableView.DevExpress.Xpf.Grid.ITableView.set_ScrollingHeaderVirtualizationMargin(Thickness value)
   at DevExpress.Xpf.Grid.Native.TableViewBehavior.UpdateViewportVisibleColumns()
   at DevExpress.Xpf.Grid.DataViewBase.AssignVisibleColumns(ObservableCollection`1 visibleColumnsList)
   at DevExpress.Xpf.Grid.DataViewBase.RebuildVisibleColumns()
   at DevExpress.Xpf.Grid.DataViewBase.OnDataChanged(Boolean rebuildVisibleColumns)
   at DevExpress.Xpf.Grid.GridViewBase.OnDataChanged(Boolean rebuildVisibleColumns)
   at DevExpress.Xpf.Grid.DataControlBase.OnDataChanged(Boolean synchronize, Boolean rebuildVisibleColumns)
   at DevExpress.Xpf.Grid.DataControlBase.OnDataCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at DevExpress.Xpf.Grid.DataControlBase.OnColumnsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at DevExpress.Xpf.Core.ObservableCollectionCore`1.<>n__FabricatedMethodb(NotifyCollectionChangedEventArgs )
   at DevExpress.Xpf.Core.ObservableCollectionCore`1.<>c__DisplayClass9.<OnCollectionChanged>b__6()
   at DevExpress.Xpf.Core.Locker.DoLockedAction(Action action)
   at DevExpress.Xpf.Core.ObservableCollectionCore`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at DevExpress.Xpf.Core.ObservableCollectionCore`1.EndUpdate()
   at DevExpress.Xpf.Grid.ColumnCollectionBase`1.EndUpdate()
   at DevExpress.Mvvm.Native.SyncCollectionHelper.EndPopulate(IList target, ISupportInitialize supportInitialize)
   at DevExpress.Mvvm.Native.SyncCollectionHelper.PopulateCore(IList target, IList source, Func`2 convertItemAction, Action`2 insertItemAction, ISupportInitialize supportInitialize, Action`1 clearItemAction)
   at DevExpress.Mvvm.Native.SyncCollectionHelper.SyncCollection(NotifyCollectionChangedEventArgs e, IList target, IList source, Func`2 convertItemAction, Action`2 insertItemAction, ISupportInitialize supportInitialize, Action`1 clearItemAction)
   at DevExpress.Xpf.Core.ItemsAttachedBehaviorCore`2.OnSourceCollectionChangedCore(Object sender, NotifyCollectionChangedEventArgs e)
   at DevExpress.Xpf.Core.ItemsAttachedBehaviorCore`2.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at DevExpress.Xpf.Core.ItemsAttachedBehaviorCore`2.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
   at System.Windows.WeakEventManager.ListenerList.DeliverEvent(Listener& listener, Object sender, EventArgs args, Type managerType)
   at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.ClearItems()
   at System.Collections.ObjectModel.Collection`1.Clear()

Regards,
Petrisor

Show previous comments (2)
DevExpress Support Team 9 years ago

    Thank you for the provided sample project, Petrisor. I was able to replicate the exception by using this project. I have passed it to our developers so they will research it thoroughly. We will let you know as soon as we get any results.

    Thanks,
    Michael

      I'm happy to hear that, and i'm really looking forward to a solution since we are before a release and this is a real ugly issue that we have.

      DevExpress Support Team 9 years ago

        Hi Petrisor,

        We have found that this issue relates to GridControl's DataContext re-setting that is caused by removing and adding the GridControl from/to a visual tree. We already fixed the exception on our side and currently are preparing a hotfix which will be available in the context of this thread in a few days. In addition, I would like to note that such a control's removing and adding (data context re-setting) may cause performance issues. We recommend you revise the relocation logic so it don't clear GridControl's DataContext.

        Thanks,
        Michael

        Answers approved by DevExpress Support

        created 9 years ago (modified 9 years ago)

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          Show previous comments (3)
          Alexander Russkov (DevExpress) 9 years ago

            Hi Petrisor,
            As a workaround, I suggest that you create a GridGroupFooterScrollablePart descendant and override the OnScrollingMarginChanged method. I have modified your project to demonstrate this approach.
            By the way, as a rule, newer minor versions are more stable than older ones, since big features that may potentially break something are usually introduced in major releases.

            Thanks,
            Alexander

              Thank you that indeed solved our issue for now and we will schedule an upgrade after the release.

              Alexander Russkov (DevExpress) 9 years ago

                You are always welcome, Petrisor. Feel free to contact us if you face any further difficulties.

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.