ButchersBoy / Dragablz

Dragable and tearable tab control for WPF
http://dragablz.net
MIT License
2.17k stars 320 forks source link

TargetInvocationException: When dynamically adding new tab while dragging the existing one #243

Open taank-s opened 4 years ago

taank-s commented 4 years ago

Hi James,

First of all thanks for building such a nice and useful project. It saved loads of my time to achieve some of the functionalities you have already implemented.

I am using this tab control in my app with MVVM pattern which creates the tabs dynamically based on the Items property binding. I need to allow user to rearrange the tab but not tear it. Everything is working great except this issue where user is dragging a tab and because of back-end event, controller is adding new tab (Initializing new View Model and adding it to Items property binding).

Inner Exception: The given key was not present in the dictionary.

at System.Collections.Generic.Dictionary2.get_Item(TKey key) at Dragablz.StackOrganiser.<>c__DisplayClass17_0.<OrganiseOnDrag>b__0(LocationInfo loc) at System.Linq.EnumerableSorter2.ComputeKeys(TElement[] elements, Int32 count) at System.Linq.EnumerableSorter1.Sort(TElement[] elements, Int32 count) at System.Linq.OrderedEnumerable1.d__1.MoveNext() at Dragablz.StackOrganiser.OrganiseOnDrag(DragablzItemsControl requestor, Size measureBounds, IEnumerable`1 siblingItems, DragablzItem dragItem) at Dragablz.DragablzItemsControl.ItemDragDelta(Object sender, DragablzDragDeltaEventArgs eventArgs)

If you can share your thoughts or guidance that will be very helpful.