为什么 WPF 在 Windows 8 中不显示 Windows 8 样式的按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14202562/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 06:56:32  来源:igfitidea点击:

Why doesn't WPF show Windows 8 style buttons in Windows 8

c#.netwpfvb.netxaml

提问by Elmo

This is a Windows 8 style button:

这是一个 Windows 8 风格的按钮:

And this is a button in .NET 4.5 WPF app:

这是 .NET 4.5 WPF 应用程序中的一个按钮:

Any ideas why WPF doesn't show the native Windows 8 style buttons? Is there a way to fix this?

任何想法为什么 WPF 不显示本机 Windows 8 样式按钮?有没有办法来解决这个问题?

采纳答案by CC Inc

What you can do is use a custom WPF styling from HERE.

您可以做的是使用来自HERE的自定义 WPF 样式。

Below is a screenshot of the styles as applied to the same WPF application in multiple states. The top is obviously Aero themed, and the bottom set is with the newly applied styles.

下面是在多个状态下应用于同一个 WPF 应用程序的样式的屏幕截图。上装明显是Aero主题,下装是新应用的款式。

And here is a link to the XAML.

这是XAML的链接。

回答by Daniel Brückner

WPF does not use any native Windows controls - it comes with its own controls and styles for different Windows versions. On Windows 7 you can find the following assemblies

WPF 不使用任何本机 Windows 控件 - 它带有适用于不同 Windows 版本的自己的控件和样式。在 Windows 7 上,您可以找到以下程序集

PresentationFramework.Aero.dll
PresentationFramework.Classic.dll
PresentationFramework.Luna.dll
PresentationFramework.Royale.dll

and I guess there is a new one for Windows 8. Because WPF is not build upon native controls it is possible to have a XP-style WPF application on Windows 7 and a Windows-7-style application on Windows XP.

我想 Windows 8 有一个新的。因为 WPF 不是基于本机控件构建的,所以可以在 Windows 7 上使用 XP 样式的 WPF 应用程序,在 Windows XP 上使用 Windows-7 样式的应用程序。

If you want to match the native Windows 8 UI better than what WPF offers out of the box, you will have to create your own styles - probably based on the styles provided by WPF.

如果您希望比 WPF 提供的开箱即用更好地匹配本机 Windows 8 UI,则必须创建自己的样式 - 可能基于 WPF 提供的样式。