mahapps :fontfamily 不使用定义的样式加载字体 nell'app.xaml.
本文关键字:nell 字体 xaml app 加载 样式 fontfamily 定义 mahapps | 更新日期: 2023-09-27 18:33:12
my app.xaml
<Application x:Class="MyProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<Style x:Key="Lato-Regular">
<Setter Property="TextElement.FontFamily" Value="pack://application:,,,/Resources/Font/#Lato-Regular" />
</Style>
<Style x:Key="Lato-Thin">
<Setter Property="TextElement.FontFamily" Value="pack://application:,,,/Resources/Font/#Lato-Thin" />
</Style>
<Style x:Key="Lato-Semibold">
<Setter Property="TextElement.FontFamily" Value="pack://application:,,,/Resources/Font/#Lato-Semibold" />
</Style>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Themes/Generic.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
我在解决方案"资源/字体/:拉托常规.ttf,拉托薄.ttf,拉托半粗体.ttf
My MainWindows.xaml on textblock:
<controls:MetroWindow x:Class="MainWindow.xaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:metro="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:p="clr-namespace:MyProject.Properties"
xmlns:res="clr-namespace:MyProject.Properties;assembly=CDA"
mc:Ignorable="d" d:DesignHeight="660" d:DesignWidth="800" Background="#DEDFE4"
Title="HomePage">
<Grid>
<TextBlock Style="{DynamicResource Lato-Regular}" MouseDown="HomePage_MouseDown" Text="HOMEPAGE" Grid.Row="3" HorizontalAlignment="Left" Margin="50,22,0,0" Foreground="#fff" FontSize="17" Height="Auto"></TextBlock>
</Grid>
</<controls:MetroWindow>
我的字体是由"始终复制"的属性设置的,它们在解决方案中。我不明白为什么不应该去,软件部分但字体仍然是WPF视图构建的标准。它可以是Mahapps包括它的字体,并排除我那些强加的我?
是的,MahApps 定义了自己的字体,并在许多控件中使用。在MahApps的源代码树''Style''Fonts.xaml中,定义了以下内容:
<FontFamily x:Key="DefaultFont">Segoe UI, Lucida Sans Unicode, Verdana</FontFamily>
<FontFamily x:Key="HeaderFontFamily">Segoe UI Light, Lucida Sans Unicode, Verdana</FontFamily>
<FontFamily x:Key="ContentFontFamily">Segoe UI, Lucida Sans Unicode, Verdana</FontFamily>
<FontFamily x:Key="ToggleSwitchFontFamily">Segoe UI Semibold, Segoe UI, Lucida Sans Unicode, Verdana</FontFamily>
<FontFamily x:Key="ToggleSwitchHeaderFontFamily">Segoe UI Semibold, Segoe UI, Lucida Sans Unicode, Verdana</FontFamily>
此外,在整个MahApps的项目中搜索Segou UI
,并且应该有一些其他项目。
就个人而言,我发现使用我的字体制作 MahApp 的最简单方法是简单地修改其源代码并构建我自己的源代码。