簡體   English   中英

具有擴展WPF工具包的MessageBox的默認Windows主題

[英]Default Windows theme for MessageBox with Extended WPF Toolkit

我在我的應用程序中使用自定義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主題?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM