Fix for Issue#2457 - Crash when rearranging TabView tabs bound to UIElements #457
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes Issue #2457 in microsoft/microsoft-ui-xaml repo.
Description
The TabViewItem's DataContext includes a UIElement (in this case a Frame) and when a tab gets dropped during a re-ordering operation that element gets reparented into a new ListView item container while it is still used in an old container because of an animation. This causes the "Element already parented" exception.
(I also reordered the 'using' statements at the top of the file)
Motivation and Context
The TabViewItem's DataContext must either not contain a UIElement or the inner ListView's ItemContainerTransitions collection must not include AddDeleteThemeTransition/ContentThemeTransition animations. The combination of both causes the crash. The ListView by itself exhibits the same behavior - this is not TabView-specific.
How Has This Been Tested?
Adhoc testing with 19H1 with System animations turned on.
Types of changes