简体   繁体   中英

Default Windows theme for MessageBox with Extended WPF Toolkit

I'm using custom MessageBox in my application and I need to apply my app style to it. So I use WPF Toolkit to create my MessageBox and I'm applying a MessageBoxStyle to my 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>

The problem is that it displays the basic Windows Vista window theme. I'd like my MessageBox to get the actual Windows theme of the machine (mine is Windows Server 2008 R2 E, but it might change if the application is run on another computer).

Is there a way to set this Windows theme "by default"?

WPF comes with the standard Windows themes on all Windows versions. You can have Aero theme with following steps:

Source: http://mrpmorris.blogspot.com/2008/05/using-vista-aero-theme-in-xp-wpf-apps.html

Add PresentationFramework.Aero to your application's references list as a requires

Edit your 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> 

Other options are :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM