将 ResourceDictionary 主题应用到简单的 MessageBox
有人知道这个吗?
我目前有一个带有一堆用户控件的应用程序。它们都以“黑暗表达”为主题。无论如何,当我使用通用代码调用“MessageBox”时:
MessageBox.Show("message", "title", MessageBoxButtons.YesNo);
它使用通用 Windows 主题。是否可以轻松创建主题消息框?我尝试使用用户控件扩展 MessageBox 类型,但不断收到错误“无法派生形式密封类型“System.Windows.MessageBox”。
主题是使用 ResourceDictionary 方式定义的:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="./Resources/Themes/ExpressionDark.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
所以它的要点是,我希望我的消息框看起来与我的应用程序相同;冷峻而忧郁的“黑暗表情”主题。现在它看起来与稍微有趣的 Win7 主题格格不入。
Does anyone know this one?
I currently have an application with a bunch of user controls. They are all themed with the "Dark Expressions" theme. Anyways, when I call on a "MessageBox" using the common code:
MessageBox.Show("message", "title", MessageBoxButtons.YesNo);
It is using the generic windows theme. Is it possible to create a themed message box very easily? I have tried expending the MessageBox type with a user control, but I keep on getting the error "Cannot derive form sealed type "System.Windows.MessageBox"
The theme is defined using the ResourceDictionary way:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="./Resources/Themes/ExpressionDark.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
So the gist of it is, I'd like my message box to look the same as my application; the cool and somber "dark expressions" theme. Right now it looks out of place with the mildly amusing Win7 theme.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
网上有很多自定义消息框,例如这个 您可以在应用主题后使用它们,也可以简单地创建自己的主题,而不是通过从 MessageBox 类派生,而是通过创建自定义控件来创建自己的主题。
There are plenty of custom message boxes available on the net like this either you can use those after applying your theme to it or you can simply create your own not by deriving from the MessageBox class but by creating a custom control.