2017-12-16 20 views
0

MetroDark 테마를 사용합니다.모든 요소의 글꼴 모음을 변경하는 방법 wpf-xaml

내가 XAML에서이 코드를 사용 :

<Application.Resources> 
     <ResourceDictionary> 
      <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary Source="Theme/MetroDark/MetroDark.MSControls.Core.Implicit.xaml" /> 
       <ResourceDictionary Source="Theme/MetroDark/MetroDark.MSControls.Toolkit.Implicit.xaml" /> 
      </ResourceDictionary.MergedDictionaries> 
      <Style TargetType="{x:Type Label}" > 
       <Setter Property="FontFamily" Value="B titr" /> 
       <Setter Property="FontSize" Value="13" /> 
       <Setter Property="FontWeight" Value="Bold" /> 
      </Style> 
      <Style TargetType="{x:Type TextBox}" > 
       <Setter Property="FontFamily" Value="B Nazanin" /> 
       <Setter Property="FontSize" Value="16" /> 
       <Setter Property="FontWeight" Value="Bold" /> 
      </Style> 
     </ResourceDictionary> 
    </Application.Resources> 

폰트 패밀리가 제대로 변경되었습니다하지만 배경 색상도 변경되었습니다.

글꼴 패밀리와 글꼴 크기를 변경하고 다른 속성 (예 : 배경, 테두리 등)을 변경하고 기본 테마 (MetroDark)에서 효과를 얻고 싶습니다.

어떻게하면됩니까? BasedOn에서

답변

0

세트의 기본 스타일은 다음과 같이 속성 :

<Style TargetType="{x:Type Label}" BasedOn="{StaticResource {x:Type Label}}"> 

<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}"> 

이 방법으로 사용자 정의 스타일은 기본 스타일의 모든 설정을 상속하고이 같은 app.xaml 변경하지만 선량

0

그 중 일부를 대체 할 수 있습니다 작동하지.

<Application x:Class="Amlaak.App" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      StartupUri="frmProduct.xaml"> 

    <Application.Resources> 
     <ResourceDictionary>    
      <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary Source="Theme/MetroDark/MetroDark.MSControls.Core.Implicit.xaml" /> 
       <ResourceDictionary Source="Theme/MetroDark/MetroDark.MSControls.Toolkit.Implicit.xaml" /> 
      </ResourceDictionary.MergedDictionaries> 
      <Style TargetType="{x:Type Label}" BasedOn="{StaticResource {x:Type Label}}"> 
       <Setter Property="FontFamily" Value="B titr" /> 
       <Setter Property="FontSize" Value="13" /> 
       <Setter Property="FontWeight" Value="Bold" /> 
      </Style> 
      <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}"> 
       <Setter Property="FontFamily" Value="B Nazanin" /> 
       <Setter Property="FontSize" Value="16" /> 
       <Setter Property="FontWeight" Value="Bold" /> 
      </Style> 
     </ResourceDictionary> 
    </Application.Resources> 
</Application>