jya*_*nks 5 wpf resources fonts label resourcedictionary
目前,我有一个包含主题/模板和字体(作为资源)的类库项目.然后我在我的主WPF应用程序项目中引用名为Shared.UI的项目.
我使用以下方法引用它:
<ResourceDictionary Source="pack://application:,,,/Shared.UI;component/Skin.xaml" />
Run Code Online (Sandbox Code Playgroud)
在MergedDictionary标记内.
我遇到的问题是主WPF应用程序无法使用项目中的字体作为资源构建.
在我的Shared.UI/Skins.xaml文件中,我有:
<!-- LABEL -->
<Style TargetType="{x:Type Label}">
<Setter Property="FontFamily" Value="./resources/#Helvetica Neue" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryBlue}" />
<Setter Property="FontSize" Value="12" />
</Style>
Run Code Online (Sandbox Code Playgroud)
我假设这在我的主WPF应用程序中不起作用,因为它自己./resources查找#Helvetica Neue并且找不到它(因为它在Shared.UI中).我试图/Shared.UI;component/resources/#Helvetica Neue在资源文件中明确引用,但这对我不起作用.
<TextBlock><Run FontFamily="/FontClassLibrary;Component/#YourFontName" FontSize="20">Your Text</Run></TextBlock>
Run Code Online (Sandbox Code Playgroud)