Как можно добавить собственный шрифт в мой проект WindowsTemplate Studio (WPF)?
Шрифт помещается в собственную папку, и это мой код App.xaml:
<Application
x:Class = "DicomCameraConfigurationCreator.App"
xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml"
Startup = "OnStartup"
Exit = "OnExit"
DispatcherUnhandledException = "OnDispatcherUnhandledException">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source = "/Styles/_FontSizes.xaml" />
<ResourceDictionary Source = "/Styles/_Thickness.xaml" />
<ResourceDictionary Source = "/Styles/MetroWindow.xaml" />
<ResourceDictionary Source = "/Styles/TextBlock.xaml" />
<!--
MahApps.Metro resource dictionaries.
Learn more about using MahApps.Metro at https://mahapps.com/
-->
<ResourceDictionary Source = "pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source = "pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source = "pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Спасибо!
Я уже выяснил, как это работает для меня:
Добавьте свой шрифт в папку «Шрифты».
yourFont.ttf (правый клик) -> Свойства:
FontFamily = "pack://application:,,,/Fonts/#password"
TextBox.FontFamily = new FontFamily(new Uri("pack://application:,,,/"), "./Fonts/#password");