Skip to content

Fix Popup/ContextMenu flicker caused by repositioning a fading out root#11735

Open
h3xds1nz wants to merge 1 commit into
dotnet:mainfrom
h3xds1nz:popup-flicker-fix
Open

Fix Popup/ContextMenu flicker caused by repositioning a fading out root#11735
h3xds1nz wants to merge 1 commit into
dotnet:mainfrom
h3xds1nz:popup-flicker-fix

Conversation

@h3xds1nz

@h3xds1nz h3xds1nz commented Jun 28, 2026

Copy link
Copy Markdown
Member

Fixes #11741

Description

When you have an app without PMA enabled (still common nowadays) and define a ContextMenu that uses Fade animation (the system default), upon attempting to reopen the ContextMenu at a different location in succession, you will observe flicker upon repositioning. This has been issue since early NETFX days, difference being that nowadays a PMA-enabled app will not observe it anymore as the window is not reused but a new one is always created due to other issues within WPF but also DWM.

This is caused by the fact that the window is reused and interrupted midst an ongoing fade-out animation, together with a call to SetWindowPos causing a repositioning, resulting in an ugly flicker.

There are two ways to fix this:

  • Disable fade out animation, which would be in-line with how Win32 (native) controls handle it, a context menu e.g. on Windows 10 only has a fade-in animation, not a fade out one, same case for pure menu strips.
    • However this introduces a visual change to the WPF ecosystem, and affects other derived controls such as Menu for no reason, potentially breaking user expectations.
  • Unconditionally use a new window even when not having a PMA-enabled app when using Fade animation.
    • This should be without side-effects, it has worked great on our apps for years.

Customer Impact

Customers will finally get their fix after 15 years / won't need to disable animations.

syncfusion/wpf-demos#23 (see video if you don't know what its about)
https://www.reddit.com/r/csharp/comments/1l8mb9o/wpf_contextmenu_flickering_issue/
https://stackoverflow.com/questions/13553456/contextmenu-of-tabcontrol-blinks-when-opened-a-second-time

Regression

No, this has been issue pretty much since the dark days.

Testing

Few years of user-facing commercial apps.

Risk

Shouldn't cause any issues, this is a path that's hit regularly with PMA-enabled apps already.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested a review from a team June 28, 2026 13:08
@h3xds1nz h3xds1nz requested a review from a team as a code owner June 28, 2026 13:08
@dotnet-policy-service dotnet-policy-service Bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Jun 28, 2026
@miloush

miloush commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Why does it not affect other animations?

@h3xds1nz

h3xds1nz commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Other animations are performed only on show, not on hide. Fade is the only exception.

Other animations hide the window (via ShowWindow call) and then destroy it instantly, Fade has a delay for a visible fade out. When you reposition the window with another right-click, the window is already destroyed with other animations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage Queue for test pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataGrid ContextMenu flickers on consecutive right-click actions

3 participants