gpt4 book ai didi

wpf - 为什么 WPF 在不同版本的 Windows 上呈现不同?

转载 作者:行者123 更新时间:2023-12-04 20:11:58 25 4
gpt4 key购买 nike

我读到 WPF 在幕后使用 DirectX 来执行其渲染,它不依赖 WinForms 用于渲染控件的恐龙库。

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

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

来自 C# 2010 Bible 中的 Pro 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.



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

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

最佳答案

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

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

如果您不想要这种行为,则必须提供 StylesTemplates适用于所有 UI 元素类型,或以其他方式找到包含 PresentationFramework.Aero.dll 的方法在您的应用程序中并将其用作默认主题库。

看看this answer

关于wpf - 为什么 WPF 在不同版本的 Windows 上呈现不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16325287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com