Meziantou。 WPFFontAwesome
在WPF应用程序中使用fontawesome
用法
使用控件
- 安装Nuget软件包
Meziantou. WPFFontAwesome - 添加XML名称空间
xmlns:fa=\"clr-namespace:Meziantou. WPFFontAwesome ;assembly=Meziantou. WPFFontAwesome \" - 使用自定义控件
< 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 \" />
使用字体
- 安装Nuget软件包
Meziantou. WPFFontAwesome - 将
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.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source=\”pack://application:,,,/Meziantou. WPFFontAwesome ;component/Themes/Generic.xaml\” />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>\”>
< 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 >
- 添加XML名称空间
xmlns:fa=\"clr-namespace:Meziantou. WPFFontAwesome ;assembly=Meziantou. WPFFontAwesome \" - 使用它
< 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 ( .. . ) ;
