矢量字体图标FontAwesome.WPF
2021-05-28 01:02
标签:ons fonts source nts icons ros present text base
FontAwesome.WPF是对FontAwesome的封装。可能会比直接使用FontAwesome要方便一点。
项目网站:https://github.com/charri/Font-Awesome-WPF
安装:
Install-Package FontAwesome.WPF
使用:
Window x:Class="Example.FontAwesome.WPF.Single"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fa="http://schemas.fontawesome.io/icons/"
Title="Single" Height="300" Width="300">
Grid Margin="20">
fa:ImageAwesome Icon="Flag" VerticalAlignment="Center" HorizontalAlignment="Center" />
Grid>
Window>
也可以使用以TextBlock为基础的:
"Flag" />
官方的解释:
The Image based ImageAwesome control is useful when you need to fill an entire space. Whereas the TextBlock base FontAwesome is useful when you need a certain FontSize.
大概的意思是:ImageAwesome比较适合根据容器填充的地方,FontAwesome适合自己去控制字体大小的地方。
也可以在一些ContentControl控件上使用,例如下面的Button:
Button fa:Awesome.Content="Flag"
TextElement.FontFamily="pack://application:,,,/FontAwesome.WPF;component/#FontAwesome"/>
后台的cs代码中使用:
Icon = ImageAwesome.CreateImageSource(FontAwesomeIcon.Flag, Brushes.Black);
一些一直在旋转的图标:
fa:ImageAwesome Icon="Spinner" Spin="True" SpinDuration="10" />
旋转指定角度或翻转图标:
fa:ImageAwesome Icon="Spinner" FlipOrientation="Horizontal" Rotation="90" />
矢量字体图标FontAwesome.WPF
标签:ons fonts source nts icons ros present text base
原文地址:https://www.cnblogs.com/wzwyc/p/14765449.html