如何设置 System.Windows.MessageBox 按钮的样式?
我在 WPF 应用程序中使用 System.Windows.MessageBox,由于某种原因,其按钮的样式采用 Windows 2000 方式 - 不是 WinXP,不是 Aero,不是 WPF 默认值。只是灰色和基本的 3D 边框。
怎样才能让它们显得更现代呢? (其实哪一个并不重要)
I'm using System.Windows.MessageBox in a WPF app, and for some reason its buttons are styled the Windows 2000 way - not WinXP, not Aero, not the WPF default. Just gray with basic 3d borders.
How can I make them appear with a more modern style? (doesn't really matter which one)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用清单修复此问题。请参阅本文以获取分步说明:为什么我使用 WPF 获得旧式文件对话框和消息框
基本上,您必须向应用程序添加一个名为“清单”的 XML 文件。
更新:
实际上,在VS2008中做到这一点非常容易。转到“项目属性”->“应用程序”,然后单击“查看 UAC 设置”按钮。这将自动创建一个应用程序清单文件并打开它。按如下方式编辑此文件:
在行之后:
粘贴到以下依赖项部分:
我的完整清单如下所示:
执行此操作后,只需构建您的应用程序,运行,瞧,MessageBox 对话框按钮将采用系统主题样式。
You can fix this with a manifest. See this article for step-by-step instructions: Why am I Getting Old Style File Dialogs and Message Boxes with WPF
Basically, you have to add an XML file called a 'manifest' to your application.
Update:
Actually, it is very easy to do this in VS2008. Go to Project Properties->Application and click the 'View UAC Settings' button. This will automatically create an application manifest file and open it. Edit this file as follows:
Just after the line:
Paste in the following dependency section:
My complete manifest looks like this:
After doing this, just build your app, run, and voila, the MessageBox dialog buttons take on the system theme style.