我在我的应用程序中使用自定义MessageBox,我需要将我的应用程序样式应用于它。所以我使用WPF Toolkit创建我的MessageBox,并且我将MessageBoxStyle应用于我的MessageBox:
C#:
Result = Xceed.Wpf.Toolkit.MessageBox.Show(
message,
title,
messageBoxButtons,
messageBoxImage,
(Style)resourceDictionary["MessageBoxStyle"]
);
XAML:
<Style x:Key="MessageBoxStyle" TargetType="{x:Type xctk:MessageBox}">
<!-- My Setters -->
</Style>
问题是它显示基本的Windows Vista窗口主题。我希望我的MessageBox能够获得该机器的实际Windows主题(我的是Windows Server 2008 R2 E,但如果应用程序在另一台计算机上运行,它可能会改变。)
有没有办法在默认情况下设置此Windows主题?
答案 0 :(得分:0)
WPF在所有Windows版本上都附带标准的Windows主题。您可以通过以下步骤获得Aero主题:
来源:http://mrpmorris.blogspot.com/2008/05/using-vista-aero-theme-in-xp-wpf-apps.html
将PresentationFramework.Aero添加到应用程序的引用列表中作为需求
编辑您的App.xaml
<Application.Resources>
<ResourceDictionary>
<!-- Put your stuff here instead -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
其他选项包括:
<ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
<ResourceDictionary Source="/PresentationFramework.Classic;component/themes/Classic.xaml"/>
<ResourceDictionary Source="/PresentationFramework.Royale;component/themes/Royale.NormalColor.xaml"/>
<ResourceDictionary Source="/PresentationFramework.Luna.Homestead;component/themes/Luna.Homestead.xaml"/>
<ResourceDictionary Source="/PresentationFramework.Luna.Metallic;component/themes/Luna.Metallic.xaml"/>
<ResourceDictionary Source="/PresentationFramework.Zune;component/themes/Zune.NormalColor.xaml"/>