1. 程式人生 > >wpf 使用Font-Awesome圖標字體

wpf 使用Font-Awesome圖標字體

css style fontsize setter always win sources key html

原文:wpf 使用Font-Awesome圖標字體

wpf 使用Font-Awesome圖標字體

1、http://fontawesome.io/ 中下載Font-Awesome字體

然後把字體文件fontawesome-webfont.ttf 拷貝到項目中

build action 設置為Resource

並設置“復制到輸出目錄”為“如果較新則復制” 或者 copy always

所有圖標對應的值內容地址

http://www.bootcss.com/p/font-awesome/design.html

\<Window x:Class="WpfApplication1.MainWindow" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
Title="MainWindow"> 
\<Window.Resources> 
\<Style x:Key="FontAwesome">
\<Setter Property="TextElement.FontFamily" Value="pack://application:,,,/#FontAwesome" />
\<Setter Property="TextBlock.Width" Value="100"></Setter>
\<Setter Property="TextBlock.Height" Value="100"></Setter>
\<Setter Property="TextBlock.TextAlignment" Value="Center"></Setter>
\<Setter Property="TextBlock.FontSize" Value="60"></Setter>
\<Setter Property="TextBlock.Foreground" Value="Green"></Setter>
\</Style>
\</Window.Resources> 
\<WrapPanel Margin="12"> 
\<TextBlock Text="&#xf01a;" Style="{DynamicResource FontAwesome}" />
\<TextBlock Text="&#xf01a;" Style="{DynamicResource FontAwesome}" />
\<TextBlock Text="&#xf01a;" Style="{DynamicResource FontAwesome}" />
\<TextBlock Text="&#xf01a;" Style="{DynamicResource FontAwesome}" />
\<TextBlock Text="&#xf01a;" Style="{DynamicResource FontAwesome}" />
\<TextBlock Text="&#xf01a;" Style="{DynamicResource FontAwesome}" />
\<TextBlock Text="&#xf01a;" Style="{DynamicResource FontAwesome}" />
\<TextBlock Text="&#xf01a;" Style="{DynamicResource FontAwesome}" />
\<TextBlock Text="&#xf01a;" Style="{DynamicResource FontAwesome}" />
\<TextBlock Text="&#xf01a;" Style="{DynamicResource FontAwesome}" />
\</WrapPanel> 
\</Window>
 

wpf 使用Font-Awesome圖標字體