简体   繁体   English

WPF上下文菜单不是Windows 10样式

[英]WPF Context Menu is not in Windows 10 Style

I'm developing a simple WPF application. 我正在开发一个简单的WPF应用程序。 I don't use any custom styling. 我不使用任何自定义样式。 So it looks native on Windows 7 and 10. But today I have noticed that the context menu looks odd on Windows 10: 因此,它看起来像Windows 7和10上的本机。但是今天我注意到,上下文菜单在Windows 10上看起来很奇怪:

屏幕截图

In other applications like 7-Zip, context menus look native: 在7-Zip等其他应用程序中,上下文菜单看起来是本机的:

邮编

How can I apply the flat Window 10 style to my context menus without breaking the native look on Windows 7? 如何在不破坏Windows 7的本机外观的情况下将平面Window 10样式应用于上下文菜单?

Clarification: My context menu has a 3D split line on the left hand and a border around the selction. 澄清:我的上下文菜单在左侧有3D分割线,并在选择周围有边框。 In 7-Zip, Explorer and other applications, there are neither a 3D split line nor a border around selctions. 在7-Zip,Explorer和其他应用程序中,没有3D分割线,也没有在选择项周围形成边框。 I'm used that WPF applications looks unlike Java Swing as a nativ Windows application. 我曾经使用过WPF应用程序,而将Java Swing看作是nativ Windows应用程序。

But today I have noticed that the context menu looks odd on Windows 10: 但是今天我注意到在Windows 10上上下文菜单看起来很奇怪:

Odd or not, this is actually how the default WPF ContextMenu looks like on Windows 10. 不管是否奇怪,这实际上是默认的WPF ContextMenu在Windows 10上的样子。

How can I apply the flat Window 10 style to my context menus without breaking the native look on Windows 7? 如何在不破坏Windows 7的本机外观的情况下将平面Window 10样式应用于上下文菜单?

You need to define this "flat Window 10 style" yourself. 您需要自己定义“平面Window 10样式”。 There is an example of how to create a custom ContextMenu style available on MSDN that should get you started: https://msdn.microsoft.com/en-us/library/ms744758%28v=vs.110%29.aspx . 有一个有关如何创建MSDN上可用的自定义ContextMenu样式的示例,可以帮助您入门: https : //msdn.microsoft.com/zh-cn/library/ms744758%28v=vs.110%29.aspx There is no quick fix. 没有快速修复。

You're getting hung up on the shortcut keys (>, Enter, Ctrl + PgDn, etc). 您会迷上快捷键(>,Enter,Ctrl + PgDn等)。 Your application isn't assigning any, while 7-zip is assigning them. 您的应用程序未分配任何内容,而7-zip 正在分配它们。 Or maybe, the outlining. 也许是大纲。 Don't get thrown off. 不要扔掉。 Things are working exactly as they should. 事情正在按预期运行。

But let's not overlook the fact that if 7-zip is not written in WPF, you can't expect the same results. 但是,请不要忽视这样一个事实,即如果7-zip不是用WPF编写的,那么您将无法期望得到相同的结果。

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

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