国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

WPF字體圖標——FontAwesom

2019-11-11 03:10:35
字體:
來源:轉載
供稿:網友

一、字體圖標概述

FontAwesome是迄今為止最出色的圖標字體(沒有之一),優點是圖標多、圖標美觀、兼容各種應用場景等。

二、獲取FontAwesome字體圖標庫

FontAwesome主頁

GitHub的下載地址

FontAwesome字體圖標列表

三、加壓下載到的字體庫壓縮包,得到字體圖標庫文件

四、像WPF字體圖標——IconFont提供的步驟調用即可,只需要將樣式引用的字體名稱改為:#FontAwesome,注意名稱大小寫,否則找不到對應的圖標

①項目目錄結構

②MyFontAwesome.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/PResentation"                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"                    xmlns:local="clr-namespace:FontAwesomeDemo">    <Style x:Key="iFont" TargetType="TextBlock">        <Setter Property="FontFamily" Value="/FontAwesomeDemo;component/Resources/#FontAwesome"/>        <Setter Property="TextAlignment" Value="Center"/>        <Setter Property="HorizontalAlignment" Value="Center"/>        <Setter Property="VerticalAlignment" Value="Center"/>        <Setter Property="FontSize" Value="20"/>    </Style></ResourceDictionary>③App.xaml
<application x:Class="FontAwesomeDemo.App"             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"             xmlns:local="clr-namespace:FontAwesomeDemo"             StartupUri="MainWindow.xaml">    <Application.Resources>        <ResourceDictionary>            <ResourceDictionary.MergedDictionaries>                <ResourceDictionary Source="MyFontAwesome.xaml"/>            </ResourceDictionary.MergedDictionaries>        </ResourceDictionary>    </Application.Resources></Application>

④MainWindow.xaml

<Window x:Class="FontAwesomeDemo.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"        xmlns:local="clr-namespace:FontAwesomeDemo"        mc:Ignorable="d"       Title="MainWindow" Height="350" Width="525" Background="Blue">    <StackPanel Orientation="Horizontal">        <TextBlock Text="?" Style="{StaticResource iFont}" FontSize="50" Margin="3" Foreground="White"></TextBlock>        <TextBlock Text="?" Style="{StaticResource iFont}" FontSize="60" Margin="3" Foreground="SandyBrown"></TextBlock>        <TextBlock Text="?" Style="{StaticResource iFont}" FontSize="70" Margin="3" Foreground="#FB0AE8"></TextBlock>        <TextBlock x:Name="QQ" Style="{StaticResource iFont}" FontSize="80" Margin="3" Foreground="Chartreuse"></TextBlock>        <TextBlock x:Name="refresh" Style="{StaticResource iFont}" FontSize="90" Margin="3" Foreground="#FEDB11"></TextBlock>    </StackPanel></Window>很奇怪Text屬性在網頁上無法顯示,三個屬性分別為:Text="&#xf1fe;"  Text="&#xf24e;"  Text="&#xf240;"

⑤MainWindow.xaml.cs

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;namespace FontAwesomeDemo{    /// <summary>    /// MainWindow.xaml 的交互邏輯    /// </summary>    public partial class MainWindow : Window    {        public MainWindow()        {            InitializeComponent();            qq.Text = "/xf1d6";            refresh.Text = "/xf021";        }    }}⑥效果演示


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 锡林郭勒盟| 榆林市| 资中县| 大埔区| 吉隆县| 仙居县| 墨玉县| 宜丰县| 高唐县| 周至县| 宁乡县| 黄陵县| 威信县| 景谷| 庆阳市| 横山县| 南昌市| 桐乡市| 鄂托克旗| 台中县| 交城县| 关岭| 临高县| 灵丘县| 禹州市| 晋中市| 洞口县| 九龙县| 勃利县| 界首市| 镇江市| 靖江市| 柳州市| 米易县| 丁青县| 秦皇岛市| 西藏| 大石桥市| 麻江县| 石家庄市| 修水县|