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>
相关推荐
大大大大晴天3 天前
Hudi技术内幕:RecordPayload到RecordMerger
大数据
SelectDB4 天前
秒级弹性、最高降本 70%:SelectDB Serverless 如何重塑云数仓资源效率
大数据·后端·云原生
WhoAmI4 天前
MapReduce框架原理解析一:InputFormat
大数据·hadoop
WhoAmI4 天前
MapReduce框架原理解析三:OutputFormat
大数据·hadoop
WhoAmI4 天前
MapReduce框架原理解析二:Shuffle
大数据·hadoop
大大大大晴天5 天前
Hudi技术内幕:Key Generation原理与实践
大数据
得物技术8 天前
从埋点需求到规则资产:Hermes Agent 重构得物数仓工作流
大数据·llm·ai编程
久美子8 天前
AI驱动数仓建设的Harness工程实践——本体建模、知识分层与上下文工程
大数据
大树889 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
大志哥1239 天前
ES和Logstash日志链路系统上线后遭遇切片爆炸(解决)
大数据·elasticsearch