2012-02-15 6 views
0

私はを持っています。暗いテーマ WPFアプリケーション用です。私が持っているものUser Controlの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> 

は、この式ダークは、すべてのユーザーコントロール(public partial class UControl : UserControl)に適用されることです。

私が欲しいのは、は、AeroまたはすべてのWPFユーザーコントロールのような全く異なるテーマを使用することです。

どうすればいいですか?

ありがとうございました!

+0

「WPFユーザーコントロール」を定義します –

+0

@jbergerパブリック部分クラスUControl:UserControl –

答えて

2

Startupイベントを作成し、Startupイベントハンドラでテーマを設定します。そのテーマはそのソリューションのすべてのユーザーコントロールに適用されます。あなたの場合。

//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   
     } 
関連する問題