編輯
忽略這個答覆,如果一切都在同一個裝配它纔會起作用。
我只是嘗試這樣做,
和它的作品對我來說
。這是我做的方式:
字體文件(ttf)位於應用程序的根目錄。構建操作是「資源」,選擇「不復制」。
我有一個「資源」文件夾,也在應用程序的根目錄。在這我有Assets1.xaml和Assets2.xaml。構建操作都是「資源」,並且「不要複製」被選中。在Assets1.xaml中,我有一些無關緊要的東西。在Assets2.xaml我把以下內容:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="DeveloperStyle"
TargetType="TextBox">
<Setter Property="FontFamily"
Value="ProggyTiny.ttf#ProggyTinyTT"></Setter>
<Setter Property="FontSize"
Value="16"></Setter>
</Style>
</ResourceDictionary>
在App.xaml中我做到這一點(請注意,我用的是基類我的應用程序,但這不應該有所作爲):
<base:BaseApplication xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:base="clr-namespace:GLS.Gui.Controls.Base;assembly=GLS.Gui.Controls"
x:Class="GLSTestApp02.App"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:h="clr-namespace:GLS.Gui.Helper;assembly=GLS.Gui.Helper">
<base:BaseApplication.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Assets1.xaml" />
<ResourceDictionary Source="Resources/Assets2.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</base:BaseApplication.Resources>
</base:BaseApplication>
當我將樣式應用於同一項目中的文本框時,它會使用自定義字體顯示。
@亨利克。謝謝你的詳細回覆。我會在今天晚些時候發佈它,並告訴你它是否全部有效。 – 2010-02-09 12:45:07
謝謝你的解釋。 – 2010-02-11 18:31:53