wpf 如何在 Windows 8 / 2012 中左对齐窗口标题?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11824181/
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 04:51:47  来源:igfitidea点击:

How to left align window title in Windows 8 / 2012?

wpfwindows-8

提问by digitguy

Is there a way to (intrinsically) left align window title in Windows 8 or 2012 machine?

有没有办法(本质上)在 Windows 8 或 2012 机器中左对齐窗口标题?

The Window's title in Window 8 or 2012 is horizontally center-aligned.

Window 8 或 2012 中的窗口标题水平居中对齐。

enter image description here

enter image description here

We have a WPF application that is ported to Windows 8 / 2012 machine. We are testing it along with couple of our clients and the clients need the title of the window to be left aligned as it was in Window 7 or XP.

我们有一个移植到 Windows 8 / 2012 机器的 WPF 应用程序。我们正在与我们的几个客户一起测试它,并且客户需要窗口的标题像在 Window 7 或 XP 中一样左对齐。

I know we can do this using ControlTemplate in WPF but that would be too much for this little thing.

我知道我们可以在 WPF 中使用 ControlTemplate 来做到这一点,但这对于这个小东西来说太过分了。

I am sure this is question is going to come up as more applications are ported to Windows 8 / 2012.

我相信随着更多应用程序被移植到 Windows 8 / 2012,这个问题将会出现。

Is there any quick solution to this? Or do you know if Microsoft is going to give this flexibility in final releases of Windows 8 or 2012?

有什么快速的解决方案吗?或者您是否知道 Microsoft 是否会在 Windows 8 或 2012 的最终版本中提供这种灵活性?

采纳答案by Jared Bienz - MSFT

All window titles in Windows 8 are center aligned. Forcing an application title to be left aligned in Windows 8 would be almost like forcing the minimize and maximize buttons to show up on the left side of the window.

Windows 8 中的所有窗口标题都居中对齐。强制应用程序标题在 Windows 8 中左对齐几乎就像强制最小化和最大化按钮显示在窗口的左侧。

You may be able to accomplish this using a custom draw window like DXWindow from DevExpress. See this post:

您可以使用 DevExpress 的 DXWindow 等自定义绘图窗口来完成此操作。看到这个帖子:

http://www.devexpress.com/Support/Center/p/Q298641.aspx

http://www.devexpress.com/Support/Center/p/Q298641.aspx

However, the application will appear out of place on Windows 8 and may not pass desktop application certification.

但是,该应用程序将在 Windows 8 上显得格格不入,并且可能无法通过桌面应用程序认证。

回答by Ryan

It is the default behavior of Windows 8, so it isn't advised.

这是 Windows 8 的默认行为,因此不建议这样做。

ALTHOUGH Visual Studio 2012 left-aligns the titles, so it is possible, however inconsistent it may be.

尽管 Visual Studio 2012 将标题左对齐,因此这是可能的,但可能不一致。

It's doubtful Microsoft will offer up how to override the default functionality or change it since it is already RTM. Thismay help you get some of the way.

微软是否会提供如何覆盖默认功能或更改它是值得怀疑的,因为它已经是 RTM。 可能会帮助您获得一些方法。