简体   繁体   English

如何将现代 Windows 10 上下文菜单与 Win32 NotifyIcon 一起使用?

[英]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.我的目标是将现代 Windows 10 主题上下文菜单与我的 C# 应用程序的托盘图标一起使用。 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. Eartrumpet 的托盘图标上下文菜单使用它,所以我知道这是可能的,但我在破译他们是如何做到这一点时遇到了很多麻烦。 Simply changing the colors is not enough, I would like to use the same design as regular Windows 10 context menus.仅仅更改 colors 是不够的,我想使用与常规 Windows 10 个上下文菜单相同的设计。

This is what I want my application's tray icon menu to look like:这就是我希望我的应用程序托盘图标菜单的样子:

现代 UWP 主题

This is what I am stuck with:这就是我所坚持的:

旧的 win32 主题

如果要在Win32应用程序中使用MenuFlyout控件,可以参考本文档 ,该文档教您如何通过Windows Community Toolkit在Win32应用程序中使用uwp控件。您也可以在Win32应用程序的窗口中托管完整的uwp页面。

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. 除了Nico Zhu的好答案之外,我认为Windows 10任务栏上下文菜单只是样式不同的普通菜单。

This opinion is made even stronger by the fact that MSFT created the “dark” theme for the File Explorer simply by restyling it. MSFT仅通过重新设置样式就为文件资源管理器创建了“深色”主题,这一观点变得更加强烈。

It is all only a different style, not new controls. 这只是一种不同的样式,而不是新的控件。

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 H.NotifyIcon.WinUI 库允许您创建支持动画和主题的本机 WinUI 上下文菜单 - https://github.com/HavenDV/H.NotifyIcon/#winui-context-menu

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM