2017-12-16 5 views
0

Ich benutze MetroDark Thema.Wie ändert man die Schriftfamilie aller Elemente wpf-xaml

Ich benutze diesen Code in 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> 

Schriftfamilie wurde geändert richtig, aber die Hintergrundfarbe wurde auch geändert.

Ich möchte nur die Schriftfamilie und Schriftgröße ändern, und eine andere Eigenschaft (wie: Hintergrund, Rahmen usw.) und Wirkung von Standardthema (MetroDark) erhalten.

Wie kann ich das tun?

Antwort

0

Satz Basis Stil in BasedOn wie dieses Attribut:

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

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

auf diese Weise individuelle Stil alle Einstellungen von Basis Stil erbt und können einige von ihnen außer Kraft setzen

0

ich app.xaml wie dies zu ändern, aber es dosieren nicht arbeiten.

<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> 
Verwandte Themen