2012-02-15 61 views
0

我有表达式黑暗主题整个 WPF应用程序。如何禁止用户控件的WPF全局应用程序主题?

<Application x:Uid="Application_1" x:Class="MyShow.Player.App" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      StartupUri="MainWindow.xaml" 
      SessionEnding="App_SessionEnding" > 
    <Application.Resources> 
     <ResourceDictionary x:Uid="ResourceDictionary_1" > 
      <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary x:Uid="ResourceDictionary_3" Source="/Themes/ExpressionDark.xaml" /> 
      </ResourceDictionary.MergedDictionaries> 
     </ResourceDictionary> 
    </Application.Resources> 
</Application> 

我所拥有的是这个Expression Dark适用于所有用户控件(public partial class UControl : UserControl)。

我想要的是使用完全不同的主题,如Aero或其他所有WPF用户控件。

我该怎么做?

谢谢!

+0

定义“WPF用户控件” – 2012-02-15 17:34:00

+0

@jberger它是公共分部类UControl:UserControl – 2012-02-15 17:43:48

回答

2

创建启动事件并在启动事件处理程序中设置主题。该主题将应用于该解决方案中的所有用户控制。在你的情况。

//App.xaml 

<Application x:Uid="Application_1" x:Class="MyShow.Player.App" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      StartupUri="MainWindow.xaml" 
      SessionEnding="App_SessionEnding" 
      Startup="Application_Startup"> 

//App.xaml.cs 

private void Application_Startup(object sender, StartupEventArgs e) 
     { 
      StyleManager.ApplicationTheme = new MetroTheme(); //Set your theme   
     } 
相关问题