ghost1372 / HandyControls

Contains some simple and commonly used WPF controls based on HandyControl
https://ghost1372.github.io/
MIT License
1.07k stars 102 forks source link

System.ArgumentOutOfRangeException occur in 3.5.0, not not occur in 3.4.5. #214

Closed nayaku closed 6 months ago

nayaku commented 9 months ago

Describe the bug

When I update the data in Model, ArgumentoutOutoFRANGEEXCEPTION will appear. But I don't know the reason and trigger. This error only appears in 3.5.0, and this error will not occur in 3.4.5.

MVVM framwork: Stylet Flolowing is my call stack:

System.ArgumentOutOfRangeException
  HResult=0x80131502
  Message=Specified argument was out of the range of valid values. Arg_ParamName_Name
  Source=WindowsBase
  StackTrace:
   在 MS.Utility.FrugalObjectList`1.get_Item(Int32 index)
   在 System.Windows.Freezable.GetChangeHandlersAndInvalidateSubProperties(EventStorage& calledHandlers)
   在 System.Windows.Freezable.FireChanged()
   在 HandyControl.Interactivity.Behavior.Detach()
   在 HandyControl.Interactivity.BehaviorCollection.ItemRemoved(Behavior item)
   在 HandyControl.Controls.PanelElement.OnFluidMoveBehaviorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   在 System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   在 System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   在 System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   在 System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
   在 System.Windows.StyleHelper.ClearTemplateChain(HybridDictionary[] instanceData, FrameworkElement feContainer, FrameworkContentElement fceContainer, List`1 templateChain, FrameworkTemplate oldFrameworkTemplate)
   在 System.Windows.StyleHelper.ClearGeneratedSubTree(HybridDictionary[] instanceData, FrameworkElement feContainer, FrameworkContentElement fceContainer, FrameworkTemplate oldFrameworkTemplate)
   在 System.Windows.StyleHelper.DoTemplateInvalidations(FrameworkElement feContainer, FrameworkTemplate oldFrameworkTemplate)
   在 System.Windows.Controls.ItemsPresenter.OnTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   在 System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   在 System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   在 System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   在 System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   在 System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   在 System.Windows.FrameworkElement.ApplyTemplate()
   在 System.Windows.Controls.ScrollContentPresenter.HookupScrollingComponents()
   在 System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   在 System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   在 System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   在 System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
   在 System.Windows.StyleHelper.InvalidateContainerDependents(DependencyObject container, FrugalStructList`1& exclusionContainerDependents, FrugalStructList`1& oldContainerDependents, FrugalStructList`1& newContainerDependents)
   在 System.Windows.StyleHelper.DoStyleInvalidations(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle)
   在 System.Windows.FrameworkElement.OnStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   在 System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   在 System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   在 System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   在 System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
   在 System.Windows.StyleHelper.InvalidateResourceDependentsForChild(DependencyObject container, DependencyObject child, Int32 childIndex, ResourcesChangeInfo info, FrameworkTemplate parentTemplate)
   在 System.Windows.TreeWalkHelper.InvalidateStyleAndReferences(DependencyObject d, ResourcesChangeInfo info, Boolean containsTypeOfKey)
   在 System.Windows.TreeWalkHelper.OnResourcesChanged(DependencyObject d, ResourcesChangeInfo info, Boolean raiseResourceChangedEvent)
   在 System.Windows.FrameworkElement.OnAncestorChangedInternal(TreeChangeInfo parentTreeState)
   在 System.Windows.TreeWalkHelper.OnAncestorChanged(DependencyObject d, TreeChangeInfo info, Boolean visitedViaVisualTree)
   在 MS.Internal.PrePostDescendentsWalker`1._VisitNode(DependencyObject d, Boolean visitedViaVisualTree)
   在 System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe, Boolean visitedViaVisualTree)
   在 System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren)
   在 System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren)
   在 System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d)
   在 MS.Internal.PrePostDescendentsWalker`1._VisitNode(DependencyObject d, Boolean visitedViaVisualTree)
   在 System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe, Boolean visitedViaVisualTree)
   在 System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren)
   在 System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d)
   在 System.Windows.DescendentsWalker`1.StartWalk(DependencyObject startNode, Boolean skipStartNode)
   在 MS.Internal.PrePostDescendentsWalker`1.StartWalk(DependencyObject startNode, Boolean skipStartNode)
   在 System.Windows.TreeWalkHelper.InvalidateOnTreeChange(FrameworkElement fe, FrameworkContentElement fce, DependencyObject parent, Boolean isAddOperation)
   在 System.Windows.FrameworkElement.OnVisualParentChanged(DependencyObject oldParent)
   在 System.Windows.Media.Visual.FireOnVisualParentChanged(DependencyObject oldParent)
   在 System.Windows.Media.Visual.RemoveVisualChild(Visual child)
   在 System.Windows.Media.VisualCollection.Clear()
   在 System.Windows.Controls.UIElementCollection.ClearInternal()
   在 System.Windows.Controls.Panel.ClearChildren()
   在 System.Windows.Controls.Panel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args)
   在 System.Windows.Controls.Panel.OnItemsChanged(Object sender, ItemsChangedEventArgs args)
   在 System.Windows.Controls.ItemContainerGenerator.OnRefresh()
   在 System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   在 System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
   在 System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   在 System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   在 System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
   在 System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   在 System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   在 System.Windows.Data.ListCollectionView.RefreshOverride()
   在 System.Windows.Data.CollectionView.RefreshInternal()
   在 System.Windows.Data.CollectionView.DeferHelper.Dispose()
   在 System.Windows.Controls.ItemCollection.SetCollectionView(CollectionView view)
   在 System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   在 System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   在 System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   在 System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   在 System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
   在 System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
   在 MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
   在 MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)
   在 System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
   在 System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)
   在 Stylet.PropertyChangedBase.<>c__DisplayClass10_0.<OnPropertyChanged>b__0()
   在 Stylet.Execute.<>c.<.cctor>b__9_0(Action a)
   在 Stylet.PropertyChangedBase.OnPropertyChanged(String propertyName)
   在 Stylet.PropertyChangedBase.NotifyOfPropertyChange(String propertyName)
   在 ImageManager.ViewModels.MainPageViewModel.set_Pictures(BindableCollection`1 value) 在 E:\code\Csharp\ImageManager3.1\ImageManager\ImageManager\ViewModels\MainPageViewModel.cs 中: 第 37 行
   在 ImageManager.ViewModels.MainPageViewModel.UpdatePicture() 在 E:\code\Csharp\ImageManager3.1\ImageManager\ImageManager\ViewModels\MainPageViewModel.cs 中: 第 211 行
   在 ImageManager.ViewModels.MainPageViewModel.UpdateIsDesc(String isDescString) 在 E:\code\Csharp\ImageManager3.1\ImageManager\ImageManager\ViewModels\MainPageViewModel.cs 中: 第 363 行
   在 System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   在 System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

File: MainPageViewModel.cs MainPageView.xaml.cs

Steps to reproduce the bug

  1. Binding Model
  2. Update Model's Data
  3. occur

Expected behavior

No response

Screenshots

No response

NuGet package version

None

IDE

Visual Studio 2022

Framework type

No response

Windows version

No response

Additional context

No response

ghost1372 commented 6 months ago

report it in original repo