sskodje / wpfchrometabs-mvvm

A tab control based on WPF chrome tabs, modified to work with the MVVM pattern
MIT License
256 stars 60 forks source link

Reordering tabs when a tab has been popped out throws exception #2

Closed vepukki closed 9 years ago

vepukki commented 9 years ago

Great work on the previous issue, I got another problem with this. Hope you can help.

When the view of the tab is very "heavy", fast actions on popping out and reordering tabs throws this error from the MoveTab:

I couldn't reproduce it with your Demo app. I think it has to do with the fact that the tabs I am handling in my app are very heavy and maybe moving the tabs is too slow to react on the changes...?

internal void MoveTab(int fromIndex, int toIndex) { if (this.Items.Count == 0 || fromIndex == toIndex) { return; } object fromTab = this.Items[fromIndex];

System.ArgumentOutOfRangeException was unhandled by user code HResult=-2146233086 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.Collections.ArrayList.get_Item(Int32 index) at System.Windows.Data.ListCollectionView.InternalItemAt(Int32 index) at ChromeTabs.ChromeTabControl.MoveTab(Int32 fromIndex, Int32 toIndex) at ChromeTabs.ChromeTabPanel.<>cDisplayClass8.b5() at ChromeTabs.ChromeTabPanel.<>cDisplayClasse.bd(Object o, EventArgs ea) at System.Windows.Media.Animation.Clock.RaiseAccumulatedEvents() at System.Windows.Media.Animation.TimeManager.RaiseEnqueuedEvents() at System.Windows.Media.Animation.TimeManager.Tick() at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(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) InnerException:

vepukki commented 9 years ago

I added this check to the MoveTab methods first check and I no longer get the error...

if (this.Items.Count == 0 || fromIndex == toIndex || fromIndex == this.Items.Count) { return; }

sskodje commented 9 years ago

I did not manage to reproduce your issue, but i will add the check for index out of range. Thank you very much for reporting it!