如何在 WPF 中设置窗口的边框和标题栏的样式? [英] How can I style the border and title bar of a window in WPF?

查看:99
本文介绍了如何在 WPF 中设置窗口的边框和标题栏的样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个 WPF 应用程序,该应用程序使用 Telerik 的控件套件,一切正常且看起来不错.不幸的是,我们最近需要替换所有对话框的基类,将 RadWindow 更改为标准 WPF 窗口(原因与本讨论无关).通过这样做,我们最终得到了一个应用程序,它在所有开发人员的计算机上看起来仍然很漂亮(启用 Aero 的 Windows 7),但在我们的客户端环境(Windows Server 2008 R2 下的终端服务)中使用时却很丑陋.

We are developing a WPF application which uses Telerik's suite of controls and everything works and looks fine. Unfortunately, we recently needed to replace the base class of all our dialogs, changing RadWindow by the standard WPF window (reason is irrelevant to this discussion). In doing so, we ended up having an application which still looked pretty on all developer's computers (Windows 7 with Aero enabled) but was ugly when used in our client's environment (Terminal Services under Windows Server 2008 R2).

Telerik 的 RadWindow 是一个标准的用户控件,它模仿对话框的行为,因此样式设置不是问题.但是,使用 WPF 的 Window,我很难改变它的边框".我在这里所说的边框"是指带有图标的标题栏和 3 个标准按钮(最小化、最大化/恢复、关闭)以及窗口周围的调整大小手柄.

Telerik's RadWindow is a standard user control that mimicks a dialog's behaviour so styling it was not an issue. With WPF's Window though, I have a hard time changing its "border". What I mean by "border" here is both the title bar with the icon and the 3 standard buttons (Minimize, Maximize/Restore, Close) and the resize grip around the window.

如何更改这些项目的外观:

How can I change the looks of these items:

  • 标题栏颜色
  • 3 个标准按钮
  • 窗口的真实边框颜色

尽可能使用圆角.

推荐答案

那些是非客户端"区域,由 Windows 控制.这里是有关该主题的 MSDN 文档(相关信息在顶部).

Those are "non-client" areas and are controlled by Windows. Here is the MSDN docs on the subject (the pertinent info is at the top).

基本上,您设置 Window 的 WindowStyle="None",然后构建您自己的窗口界面.(关于 SO 的类似问题)

Basically, you set your Window's WindowStyle="None", then build your own window interface. (similar question on SO)

这篇关于如何在 WPF 中设置窗口的边框和标题栏的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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