为什么我不能从资源中获取自定义字体?

Dar*_*Zon 2 c# silverlight wpf resources xaml

我有一个库,其中包含一个ThemeResources文件,其中包含样式.

在此输入图像描述

在Fonts文件夹中,我有一个字体文件BuxtonSketch.ttf.构建操作与RESOURCE一样

在此输入图像描述

在ThemeResources中,我定义了字体:

<FontFamily x:Key="FontFamily-Sketch">pack://application:,,,/Resources/Fonts/#Buxton Sketch</FontFamily>

<Style x:Key="TextNormalStyle" TargetType="TextBlock">
    <Setter Property="FontFamily" Value="{StaticResource FontFamily-Sketch}" />
</Style>
Run Code Online (Sandbox Code Playgroud)

由于我的UserControl调用了ProblemUserControl,我调用了但是没有工作

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Resources/ThemeResources.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</UserControl.Resources>

<Grid>
    <TextBlock Text="La pelicula PROMETHEUS!" Style="{StaticResource TextNormalStyle}" />
</Grid>
Run Code Online (Sandbox Code Playgroud)

可能会发生什么?

Sha*_*rot 5

此博客此博客都使用以下语法来使用自定义字体

博客1:

<TextBlock Text="SOTC Custom Fonts!" FontFamily="VINERITC.TTF#Viner Hand ITC"/>
Run Code Online (Sandbox Code Playgroud)

blog2:

<TextBlock Text="Gothic" FontFamily="./GOTHIC.TTF#Century Gothic"/>
Run Code Online (Sandbox Code Playgroud)

所以对你来说我认为会是

<TextBlock Text="Buxton" FontFamily="BuxtonSketch.TTF#Buxton Sketch"/>
Run Code Online (Sandbox Code Playgroud)

或者你的风格

<Style x:Key="TextNormalStyle" TargetType="TextBlock">
    <Setter Property="FontFamily" Value="BuxtonSketch.TTF#Buxton Sketch" />
</Style>
Run Code Online (Sandbox Code Playgroud)

您可能需要包含文件夹位置,但不确定

<TextBlock Text="Buxton" FontFamily="Resources/Fonts/BuxtonSketch.TTF#Buxton Sketch"/>
Run Code Online (Sandbox Code Playgroud)