Learn WPF-Use Font-Awesome icon Font, wpffont-awesome
Icon font description
Before introducing the icon font, I have to introduce the ICONICON format. In our operating system, various applications contain an icon. For example, the icon of the QQ program is a cute penguin, my computer is a display icon -------------- an icon file is extension. ICO or ICON files can still be seen everywhere in computer programs until now, but sometimes it is necessary to enlarge the ICON without losing sight of it because the ICON itself is not very different from the JPEG \ PNG format, it is also a non-vector image, so it is difficult for the icon file to meet this requirement -------------- to solve this problem, some authors put the graphic information in the Font, And the Font-Awesome we will use today is an implementation of this technical form (of course there are other ways to solve this problem, for example, if you use css3 to draw an icon, it is difficult to apply it to the client program.) -------------- there are many common icon fonts, however, I think Font-Awesome is by far the most outstanding icon Font (none) with many icons, beautiful icons, and compatibility with various application scenarios.
Use Font-Awesome icon Font in WPF
I used the Font-Awesome icon Font in the Qt application, which is very convenient to use, the display effect is as expected, but using the icon font in the WPF application will display a box, as shown in<Window x: Class = "WpfApplication1.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="" Style="{DynamicResource FontAwesome}" /><TextBlock Text="" Style="{DynamicResource FontAwesome}" /><TextBlock Text="" Style="{DynamicResource FontAwesome}" /><TextBlock Text="" Style="{DynamicResource FontAwesome}" /><TextBlock Text="" Style="{DynamicResource FontAwesome}" /><TextBlock Text="" Style="{DynamicResource FontAwesome}" /><TextBlock Text="" Style="{DynamicResource FontAwesome}" /><TextBlock Text="" Style="{DynamicResource FontAwesome}" /><TextBlock Text="" Style="{DynamicResource FontAwesome}" /><TextBlock Text="" Style="{DynamicResource FontAwesome}" />
</WrapPanel>
Modify record: Compile the sample program and complete part of the article content: modify part of the content, modify the document format
References
add-icon-font-in-wpfchanging-font-icon-in-wpf-using-font-awesome