Fix ContentDialog entrance animation not playing with OptimizeApplyStyles - #11736
Open
Mike Crider (codendone) wants to merge 1 commit into
Open
Fix ContentDialog entrance animation not playing with OptimizeApplyStyles#11736Mike Crider (codendone) wants to merge 1 commit into
Mike Crider (codendone) wants to merge 1 commit into
Conversation
…yles (GitHub #11257) Under OptimizeApplyStyles, a CControl's built-in style (which supplies the control's Template) is applied lazily only when the control goes live (CreationComplete / EnterImpl). ContentDialog::ShowAsync explicitly calls ApplyTemplate() on the not-yet-live dialog, so GetTemplate() returned null, the template wasn't expanded, and named template parts (LayoutRoot / SmokeLayerBackground) resolved late once the dialog went live. That late resolution triggered a second HostDialogWithinPopup re-parent, which cancelled the ContentDialogOpenCloseThemeTransition entrance animation. Add a CControl::ApplyTemplate override that ensures the built-in style is applied before the base class expands the template. Factor the theme-guarded style application shared with EnterImpl into EnsureBuiltInStyleApplied(), which no-ops once the style has already been applied so compat mode and already-live controls are unaffected.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
Author
|
/azp run |
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. |
hoshiizumiya
added a commit
to hoshiizumiya/OpenNet
that referenced
this pull request
Sep 1, 2026
Added detailed IPv4/IPv6 TCP/UDP port reachability status to main view and NAT detector, including new UI flyouts and quick port test. Refactored detection logic for independent protocol probing, improved timeout/evidence reporting, and parallel checks. Enhanced NATDetectorWindow to show endpoints, per-protocol results, and RFC 5780 filtering. MainViewModel now refreshes port state per protocol/address family on a dedicated thread. Updated README with build requirements and clarified Windows 10 support. Improved error handling, concurrency, and UI responsiveness. Sync: lgztx96/CommunityToolkit.WinUI@0a6bf76 Add XamlResource in the App.xaml to mitigate the Dialog custom style setting regression - microsoft/microsoft-ui-xaml#11736
| { | ||
| if (OptionalChangeState::IsOptimizeApplyStylesEnabled()) | ||
| { | ||
| IFC_RETURN(EnsureBuiltInStyleApplied()); |
Contributor
There was a problem hiding this comment.
We seem to apply only the built-in style here, while any explicit or implicit Style still lands later in EnterImpl. If that style carries a different ControlTemplate, the template we expand now gets torn down and expanded again, so OnApplyTemplate runs twice and we may hit the same reparenting problem this change is trying to avoid. The new test uses DefaultContentDialogStyle, which resolves to the same ControlTemplate as the built-in style, so it probably won't catch this. Please check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix problem where ContentDialog entrance animation commonly won't play with the OptimizeApplyStyles optional change enabled.
Fixes
Fixes #11257
PR Type
Description
Current Behavior
Under OptimizeApplyStyles, a CControl's built-in style (which supplies the control's Template) is applied lazily only when the control goes live (CreationComplete / EnterImpl). ContentDialog::ShowAsync explicitly calls ApplyTemplate() on the not-yet-live dialog, so GetTemplate() returned null, the template wasn't expanded, and named template parts (LayoutRoot / SmokeLayerBackground) resolved late once the dialog went live. That late resolution triggered a second HostDialogWithinPopup re-parent, which cancelled the ContentDialogOpenCloseThemeTransition entrance animation.
New Behavior
Add a CControl::ApplyTemplate override that ensures the built-in style is applied before the base class expands the template. With the style always applied, the associated entrance animation correctly plays.
Tests for performance shows the original performance fix is still effective in avoiding unnecessary style application.
Customer Impact
Enabling the OptimizeApplyStyles optional change prior to this fix causes a regression. With this fix, apps are free to enable that performance optimization without this regression.
Regression Potential
How Has This Been Tested?