2014-06-20 1 views
1

MahApps Metro 앱에 Window Border 스타일을 설정하려고합니다. 다른 테두리 스타일을 설정하는 방법에 대한 기사를 읽었습니다. 그러나 내 응용 프로그램의 모든 창에 테두리 스타일을 동일하게 설정하려고합니다 (모든 그림자). 작동하지 않는 것 같습니다.MahApps Metro 설정 창 App Resources의 테두리 스타일

<Application.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="pack://application:,,,/GSDXThemes;component/GSDXDarkYellowTheme.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

내 리소스 사전은 다음과 같습니다 :

<!-- Merge in ResourceDictionaries defining base styles to use. This theme is based on the Metro Dark Yellow theme. --> 
<ResourceDictionary.MergedDictionaries> 
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /> 
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> 
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> 
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Yellow.xaml" /> 
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" /> 
    <ResourceDictionary Source="pack://application:,,,/GSDXThemes;component/GSDXControlStyles.xaml" /> 
</ResourceDictionary.MergedDictionaries> 

GSDXControlStyles 사전 그냥 내 응용 프로그램에 대한 몇 가지 사용자 정의 스타일 값을 설정

나는 다음과 같이 응용 프로그램 자원을 가지고있다. 이 파일에 Window Borders를 설정하려고합니다.

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:resx="clr-namespace:GSDXThemes.Properties" 
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
       xmlns:System="clr-namespace:System;assembly=mscorlib" 
       xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
       xmlns:GSDUserControls="clr-namespace:GSD.CommonGUI.UserControls;assembly=CommonGUI"> 

<ResourceDictionary.MergedDictionaries> 
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> 
</ResourceDictionary.MergedDictionaries> 

<!-- Now customize the theme for our use...mostly just changing font sizes, etc...--> 
<Style TargetType="{x:Type Controls:MetroWindow}" > 
    <Setter Property="WindowTransitionsEnabled" Value="False" /> 
    <Setter Property="EnableDWMDropShadow" Value="True" /> 
</Style> 

<Style TargetType="{x:Type Label}" BasedOn="{StaticResource MetroLabel}"> 
    <Setter Property="FontSize" Value="16"/> 
</Style> 

<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MetroTextBox}"> 
    <Setter Property="FontSize" Value="16"/> 
</Style> 
... 

다른 모든 스타일 설정이 정상적으로 작동합니다. 그러나 창 경계를 설정하는 첫 번째 줄은 아무 것도하지 않습니다. 내 모든 창은 국경없이 보여.

어떻게하면 모든 Windows가 그림자 음영 테두리를 가질 수 있습니까?

답변

2

당신이 당신의 스타일을

<Style x:Key="CustomDefaultWindowStyle" 
     TargetType="{x:Type Controls:MetroWindow}" 
     BasedOn="{StaticResource {x:Type Controls:MetroWindow}}" > 
    <Setter Property="WindowTransitionsEnabled" Value="False" /> 
    <Setter Property="EnableDWMDropShadow" Value="True" /> 
</Style> 

지금에이 스타일을 사용하는 작업 솔루션을 얻을 수있는 키를 제공해야합니다 모든 MetroWindow

<Controls:MetroWindow x:Class="YourWindowClass" 
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
         xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
         xmlns:System="clr-namespace:System;assembly=mscorlib" 
         Title="Custom Window Style Demo" 
         Height="600" 
         Width="800" 
         WindowStartupLocation="CenterScreen" 
         Style="{DynamicResource CustomDefaultWindowStyle}"> 
... 
</Controls:MetroWindow> 

(the'Invalid 스타일을 두려워하지 않는다 대상 유형 : ... '메시지, VS 버그)

희망 하시겠습니까?

관련 문제