meziantou / WPFFontAwesome

Use FontAwesome in WPF application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Meziantou.WpfFontAwesome

NuGet GitHub license publish

Use FontAwesome in WPF application

Usage

Use the control

  1. Install Nuget package Meziantou.WpfFontAwesome
  2. Add the xml namespace xmlns:fa="clr-namespace:Meziantou.WpfFontAwesome;assembly=Meziantou.WpfFontAwesome"
  3. Use the custom control
<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" />

Use the font

  1. Install Nuget package Meziantou.WpfFontAwesome
  2. Add the ResourceDictionary to the app.xaml file
<Application x:Class="Meziantou.WpfFontAwesome.Demo.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>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Meziantou.WpfFontAwesome;component/Themes/Generic.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
  1. Add the xml namespace xmlns:fa="clr-namespace:Meziantou.WpfFontAwesome;assembly=Meziantou.WpfFontAwesome"
  2. Use it
<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" />

Use the Pro icon

If you want to use a Pro icon, you need to load the font first:

FontAwesomeIcon.ProSolidFontFamily = new FontFamily(...);

About

Use FontAwesome in WPF application

License:MIT License


Languages

Language:C# 100.0%Language:PowerShell 0.0%