Sample-TabView-TearOff icon indicating copy to clipboard operation
Sample-TabView-TearOff copied to clipboard

Redocking last Tab causes exception below build 17763.

Open PaulaScholz opened this issue 7 years ago • 4 comments

When a Tab is moved from the application to the desktop, it works fine. Other tabs may now also be moved to the new window. You may also move tabs back to the original window, but when you try to move the last desktop tab back to the main application window, an exception occurs in MainPage.xaml.cs Items_DragItemsCompleted.

Details:

System.ArgumentException HResult=0x80070057 Message=Value does not fall within the expected range. Source=<Cannot evaluate the exception source> StackTrace: at Windows.UI.Xaml.Controls.Primitives.Selector.put_SelectedIndex(Int32 value) at Microsoft.Toolkit.Uwp.UI.Controls.TabView.OnItemsChanged(Object e) at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at TabViewTear.Views.MainPage.<Items_DragItemsCompleted>d__19.MoveNext()

exceptionwindow

codesnippetwithexception

For fun, I am going to try to fix it.

PaulaScholz avatar Nov 20 '18 21:11 PaulaScholz

Thanks for the report @PaulaScholz, looks like an issue on builds before 17763, I'll have to spin up a VM after the holiday and take a look in more depth.

I would imagine this is a timing issue with the tab not being put back from the drag operation to remove again, there's some oddness with how dragging works there. I wonder if we dispatch the code in the DragItemsCompleted to the next cycle if it'd fix it or not.

michael-hawker avatar Nov 21 '18 18:11 michael-hawker

No joy on the dispatch.

dispatchexception

PaulaScholz avatar Nov 21 '18 18:11 PaulaScholz

Interestingly, putting TabItems.RemoveAt(value); in a Try/Catch block and eating the exception clears up the behavior and the app then operates normally.

But, eating exceptions is no way to live your life. Unhandled exceptions taste horrible.

"If you eat the exception, it'll work." - Famous Last Words

PaulaScholz avatar Nov 21 '18 20:11 PaulaScholz

I have the sample running on a 16299 VM and can repro the issue now. I was slowed down a bit by a toolkit issue, but I think I have a resolution for that.

michael-hawker avatar Nov 29 '18 21:11 michael-hawker