'How can I use a modern Windows 10 context menu with a Win32 NotifyIcon?

My goal is to use the modern Windows 10 themed context menu with my C# application's tray icon. Eartrumpet's tray icon context menu uses it so I know it is possible, but I have had a lot of trouble deciphering how they did it. Simply changing the colors is not enough, I would like to use the same design as regular Windows 10 context menus.

This is what I want my application's tray icon menu to look like:

Modern UWP theme

This is what I am stuck with:

Old win32 theme



Solution 1:[1]

Apart from the great answer of Nico Zhu, I think that the Windows 10 taskbar context menu is just the normal one only styled differently.

This opinion is made even stronger by the fact that MSFT created the “dark” theme for the File Explorer simply by restyling it.

It is all only a different style, not new controls.

Solution 2:[2]

If you want to use MenuFlyout control in Win32 app, You could refer this document that teach how to use uwp control in win32 app via Windows Community Toolkit You could also host the complete uwp page in Win32 app's window.

Solution 3:[3]

H.NotifyIcon.WinUI library allows you to create a native WinUI context menu with support for animations and themes - https://github.com/HavenDV/H.NotifyIcon/#winui-context-menu

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Luca Lindholm
Solution 2 Nico Zhu - MSFT
Solution 3 Konstantin S.