【问题标题】:Default Windows theme for MessageBox with Extended WPF Toolkit带有扩展 WPF 工具包的 MessageBox 的默认 Windows 主题
【发布时间】:2017-07-30 06:04:08
【问题描述】:

我在我的应用程序中使用自定义 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 主题?

【问题讨论】:

    标签: c# wpf xaml wpftoolkit


    【解决方案1】:

    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"/>
    

    【讨论】:

    • 嗨,重点是它已经是 Aero,我希望它成为标准的 Windows 主题。我的 WPF 窗口的其余部分具有正确的主题,但是使用 Xceed Extended WPF Toolkit 显示的 MessageBoxes 直接使用 Aero 主题显示。我想阻止 WPF Toolkit 更改我的 MessageBox 主题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-20
    • 2017-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多