为什么 WPF 在不同版本的 Windows 上呈现不同? [英] Why WPF renders differently on different versions of Windows?

查看:71
本文介绍了为什么 WPF 在不同版本的 Windows 上呈现不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到 WPF 在底层使用 DirectX 来执行其渲染,它不依赖 WinForms 用来渲染控件的恐龙库.

I read that WPF uses DirectX under the hood to perform its rendering, that it doesn't rely on the dinosaurian libraries that WinForms uses to render controls.

所以我用 WPF 制作了我的展示层,它在 Win8 下看起来应该是这样.

So I made my Presentation layer with WPF and it looks the way it should under Win8.

然后我将该项目部署到 Windows Server 2003... 发现我漂亮的小自定义消息框看起来非常像 WinForms 并且有点笨拙;按钮控件非常类似于 WinForms 控件,扩展控件不再显示为带圆圈的 ^ 箭头,看起来像是在 1998 年绘制的(图片 ^ 箭头当鼠标悬停在一个丑陋的方形扁平按钮上时会弹出).

Then I deployed the project to Windows Server 2003... to find out that my nice little custom message box looks awfully WinForms-like and somewhat clunky; the button controls are VERY similar to the WinForms ones, the expander control is no longer shown as a circled ^ arrow and looks like it was drawn in 1998 (picture the ^ arrow on an ugly square flat button that pops up when your mouse hovers over it).

来自C# 2010 中的 Pro WPF 圣经:

WPF 的部分承诺是您无需担心特定硬件的细节和特性.WPF 足够智能,可以在可能的情况下使用硬件优化,但它对所有内容都有软件回退.因此,如果您在带有旧显卡的计算机上运行 WPF 应用程序,界面仍会按照您设计的方式显示.

Part of the promise of WPF is that you don't need to worry about the details and idiosyncrasies of specific hardware. WPF is intelligent enough to use hardware optimizations where possible, but it has a software fallback for everything. So if you run a WPF application on a computer with a legacy video card, the interface will still appear the way you designed it.

所以,这是谎言吗?对我来说是,因为它看起来不像我设计的那样.

So, is this a lie? To me it is, because it doesn't appear the way I designed it.

如果不是,那么为什么/如何不考虑运行它的机器而呈现相同的东西?软件回退是为了模仿 Win32/GDI 渲染而设计的吗?有没有办法让我的小自定义消息框在 Win8 和 WinServer2K3 上看起来相同?

If not, then why/how doesn't the thing render identically regardless of the machine that's running it? Is the software fallback somehow designed to mimick Win32/GDI rendering? Is there a way to get my little custom message box to look identical on Win8 and WinServer2K3?

推荐答案

这与 DirectX/渲染/显卡/任何一个无关.

That has NOTHING to do with DirectX / Rendering / video card / any of that.

与 WPF 相关的所有事情都采用 Windows 主题中所有 UI 元素的默认外观.

and EVERYTHING to do with WPF taking the DEFAULT appearance of ALL UI Elements from the Windows Theme.

如果您不想要这种行为,则必须为所有 UI 元素类型提供 StylesTemplates,或者找到一种包含 PresentationFramework.Aero.dll 并将其用作默认主题库.

If you don't want this behavior, you'll have to provide Styles and Templates for ALL UI element types, or otherwise find a way to include PresentationFramework.Aero.dll in your application and use that as the default theme library.

看看这个答案

这篇关于为什么 WPF 在不同版本的 Windows 上呈现不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆