WPF界面设计-更改按钮样式 自定义字体图标

一、下载图标文件

iconfont-阿里巴巴矢量图标库

二、xaml界面代码编辑

文件结构

 对应的图标代码

Fonts/#iconfont 对应文件位置

html 复制代码
<Window.Resources>
    <ControlTemplate TargetType="Button" x:Key="CloseButtonTemplate">
        <Grid Background="Transparent" Name="back">
            <TextBlock Text="&#xe653;" FontFamily="Fonts/#iconfont" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="red" TargetName="back"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
</Window.Resources>
html 复制代码
<Grid ShowGridLines="True">
    <Grid.RowDefinitions>
        <RowDefinition Height="30" />
        <RowDefinition Height="30"/>
        <RowDefinition Height="50"/>
    </Grid.RowDefinitions>

    <Button HorizontalAlignment="Right" Content="X" Margin="0,0,0,0" Width="60" Height="30" BorderThickness="0" 
    Template="{StaticResource CloseButtonTemplate}"/>
    
</Grid>
相关推荐
数据与人工智能律师2 小时前
虚拟主播肖像权保护,数字时代的法律博弈
大数据·网络·人工智能·算法·区块链
一只专注api接口开发的技术猿4 小时前
企业级电商数据对接:1688 商品详情 API 接口开发与优化实践
大数据·前端·爬虫
今天我又学废了6 小时前
Spark,SparkSQL操作Mysql, 创建数据库和表
大数据·mysql·spark
yyywoaini~6 小时前
序列化和反序列化hadoop实现
hadoop·eclipse·php
薇晶晶7 小时前
hadoop中spark基本介绍
hadoop
杰克逊的日记7 小时前
Flink运维要点
大数据·运维·flink
hnlucky9 小时前
Windows 上安装下载并配置 Apache Maven
java·hadoop·windows·学习·maven·apache
markuszhang11 小时前
Elasticsearch 官网阅读之 Term-level Queries
大数据·elasticsearch·搜索引擎
Hello World......12 小时前
Java求职面试:从核心技术到大数据与AI的场景应用
大数据·java面试·技术栈·互联网大厂·ai服务
python算法(魔法师版)14 小时前
.NET NativeAOT 指南
java·大数据·linux·jvm·.net