Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Issue#2457 - Crash when rearranging TabView tabs bound to UIElements #457

Closed
wants to merge 2 commits into from

Conversation

RBrid
Copy link
Contributor

@RBrid RBrid commented May 29, 2020

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)


InitializeDataBindingSampleData();
}

private void TabViewPage_Loaded(object sender, RoutedEventArgs e)
Copy link
Contributor

@stmoy stmoy May 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a heavy hammer; yes, it avoids the crash, but this chunk of code is divorced from the problem sample. I'm following up over on the main thread.

If the resulting guidance is "disable the animation for the TabView", I think we'll want to localize the code to disable to the specific sample itself so it is more obvious what is happening and also to help increase copy-paste'ability.

@stmoy
Copy link
Contributor

stmoy commented Jun 8, 2020

We're investigating a framework-side fix for this common case. Closing this PR for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants