WPF:使用 TrueType 字体文件
前言
IconFont 是阿里巴巴矢量图标库。我们可以在这个网站上收藏或创建自己的图标库。
图标库下载后,包含下列内容(如图所示):
我们得到 iconfont.ttf 文件后,就开始学习如何在 WPF 中使用。
使用教程
设置资源文件 iconfont.ttf 资源属性
右键 iconfont.ttf 属性,查看字体标题
定义字体资源
<FontFamily x:Key="FontFamily.Icon">pack://application:,,,/程序集;Component/#字体标题</FontFamily>
双击 demo_index 网页文件,查看 Unicode
在 Xaml 中使用
<Window x:Class="iDemo.IconFontDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:iDemo.IconFontDemo"
xmlns:s="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Title="MainWindow" Height="600" Width="800">
<Window.Resources>
<FontFamily x:Key="FontFamily.Icon">pack://application:,,,/iDemo.Resources;Component/IconFont/#iconfont</FontFamily>
<s:String x:Key="IconCode.ColorPicker"></s:String>
<s:String x:Key="IconCode.Loading"></s:String>
<s:String x:Key="IconCode.Clock"></s:String>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="{StaticResource FontFamily.Icon}"></Setter>
<Setter Property="FontSize" Value="16"></Setter>
<Setter Property="Background" Value="Black"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
</Style>
</Window.Resources>
<Grid>
<WrapPanel>
<TextBlock Text="{StaticResource IconCode.ColorPicker}"></TextBlock>
<TextBlock Text="{StaticResource IconCode.Loading}"></TextBlock>
<TextBlock Text="{StaticResource IconCode.Clock}"></TextBlock>
</WrapPanel>
</Grid>
</Window>
推荐这些文章:
正常编写:
<TextBlock >
<Run Text="F"></Run>
<Run Text="60"></Run>
<Run Text="五4">&...
一、资源引用
语法:
//基本语法
pack://application:,,,/项目名称;component/文件名称
//引用字体
<TextBlock Text="" FontFamily="pack://application:,,,/WpfApp3;component/Fon...
一、vim core-site.xml
<!-- core指定 NameNode 的地址 -->
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop101:8020</value>
</...
<property>
<name>dfs.namenode.http-address</name>
<value>node1:50070</value>
</property>
<property>
&l...
WPF dev 根据数据修改GridControl行背景色或字体颜色
在dxg:TableView下添加:
<dxg:TableView.RowStyle>
<Style TargetType="dxg:RowControl" >
<Style.Triggers>
...
一、vim hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="https://www.cnblogs.com/fi0108/p/configuratio...
<DatePicker Name="picker" Grid.Column="5" Grid.Row="0" SelectedDate="{Binding Patient.Birthday, StringFormat=yyyy-MM-dd, Converter={StaticResource DateConver...
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapre...
使用类做为Dictionary<T,K>的key需什么要求?
问题
<P> </P>
最佳回答
没有要求
...
最关键的三个属性我已经高亮标记为红色
<Window x:Class="Walterlv.Demo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http...
文章链接:https://www.dianjilingqu.com/51340.html
本文章来源于网络,版权归原作者所有,如果本站文章侵犯了您的权益,请联系我们删除,联系邮箱:saisai#email.cn,感谢支持理解。