2012-07-27 78 views
2

我正在創建一個資源文件以用於我們的新WPF應用程序。 我可以創建顏色模板如下:WPF樣式 - 創建字體模板

<SolidColorBrush x:Key="BorderColorBrush" Color="Black"/> 
<SolidColorBrush x:Key="NavigationBorderColorBrush" Color="#FF26425D" /> 
<SolidColorBrush x:Key="ListBorderColorBrush" Color="#FF59593E"/> 

但我怎麼做同樣的字體?即:一個基本類型的字體家族?

在此先感謝

回答

1

如果你想創建自己的字體,我認爲WPF不能幫助你。但是,如果你希望所有的標籤和文字是一種格式,可以使用Style的控制和TextBlock的:

 <Window.Resources> 
      <Style TargetType="Control"> 
       <Setter Property="FontFamily" Value="Courier New" /> 
       <Setter Property="Foreground" Value="Red" /> 
      </Style> 
      <Style TargetType="TextBlock"> 
       <Setter Property="FontFamily" Value="Courier New" /> 
       <Setter Property="Foreground" Value="Red" /> 
      </Style> 
     </Window.Resources> 

因爲TextBlock不是一個子類的Control,你應該這樣做兩次。 (糾正我,如果它錯了)

+1

管理這樣做 Ariel 11 melspring 2012-07-30 23:36:06