WPFFontAwesome

字体下载 2025-07-31

Meziantou。 WPFFontAwesome

在WPF应用程序中使用fontawesome

用法

使用控件

  1. 安装Nuget软件包Meziantou. WPFFontAwesome
  2. 添加XML名称空间xmlns:fa="clr-namespace:Meziantou. WPFFontAwesome ;assembly=Meziantou. WPFFontAwesome "
  3. 使用自定义控件
< fa : FontAwesomeIcon SolidIcon = " AddressBook " FontSize = " 60 " />
< fa : FontAwesomeIcon RegularIcon = " AddressBook " FontSize = " 60 " />
< fa : FontAwesomeIcon BrandIcon = " Microsoft " FontSize = " 60 " />
< fa : FontAwesomeIcon SolidIcon = " Spinner " AnimationType = " Spin " FontSize = " 60 " />
< fa : FontAwesomeIcon SolidIcon = " Spinner " AnimationType = " Pulse " FontSize = " 60 " />

使用字体

  1. 安装Nuget软件包Meziantou. WPFFontAwesome
  2. ResourceDictionary添加到app.xaml文件中
WPFFontAwesome.Demo.App" xmlns="http://schemas.mic*r*os*oft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.mic*r*os*oft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> ">
< Application x : Class = " Meziantou. WPFFontAwesome .Demo.App "
             xmlns = " http://schemas.mic*r*os*oft.com/winfx/2006/xaml/presentation "
             xmlns : x = " http://schemas.mic*r*os*oft.com/winfx/2006/xaml "
             StartupUri = " MainWindow.xaml " >
    < Application .Resources>
        < ResourceDictionary >
            < ResourceDictionary .MergedDictionaries>
                < ResourceDictionary Source = " pack://application:,,,/Meziantou. WPFFontAwesome ;component/Themes/Generic.xaml " />
            ResourceDictionary .MergedDictionaries>
        ResourceDictionary >
    Application .Resources>
Application >
  1. 添加XML名称空间xmlns:fa="clr-namespace:Meziantou. WPFFontAwesome ;assembly=Meziantou. WPFFontAwesome "
  2. 使用它
< fa : FontAwesomeIcon SolidIcon = " AddressBook " FontSize = " 60 " />
< fa : FontAwesomeIcon RegularIcon = " AddressBook " FontSize = " 60 " />
< fa : FontAwesomeIcon BrandIcon = " Microsoft " FontSize = " 60 " />
< fa : FontAwesomeIcon SolidIcon = " Spinner " AnimationType = " Spin " FontSize = " 60 " />
< fa : FontAwesomeIcon SolidIcon = " Spinner " AnimationType = " Pulse " FontSize = " 60 " />

< TextBlock Text = " {fa:Icon AddressBook} " Style = " {StaticResource FontAwesomeRegular} " FontSize = " 60 " />
< TextBlock Text = " {fa:Icon AddressBook} " Style = " {StaticResource FontAwesomeSolid} " FontSize = " 60 " />
< TextBlock Text = " {fa:Icon FontAwesome} " Style = " {StaticResource FontAwesomeBrand} " FontSize = " 60 " />
< TextBlock Text = " {fa:Icon Spinner} " Style = " {StaticResource FontAwesomeSolidSpin} " FontSize = " 60 " />
< TextBlock Text = " {fa:Icon Spinner} " Style = " {StaticResource FontAwesomeSolidPulse} " FontSize = " 60 " />

使用专业图标

如果要使用Pro图标,则需要首先加载字体:

 FontAwesomeIcon . ProSolidFontFamily = new FontFamily ( .. . ) ;
下载源码

通过命令行克隆项目:

git clone https://github.com/meziantou/WPFFontAwesome.git