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

一、下载图标文件 



iconfont-阿里巴巴矢量图标库

二、xaml界面代码编辑

文件结构

           对应的图标代码

Fonts/#iconfont   对应文件位置

<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>
<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>

相关推荐

  1. Wpf-定义图标Button

    2024-07-10 02:54:05       35 阅读
  2. WPF 定义按钮类实现

    2024-07-10 02:54:05       39 阅读
  3. C#WPF设置圆角按钮样式

    2024-07-10 02:54:05       29 阅读
  4. wpf中引用定义字体

    2024-07-10 02:54:05       32 阅读
  5. wpf 按钮禁用样式

    2024-07-10 02:54:05       30 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-10 02:54:05       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-10 02:54:05       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-10 02:54:05       57 阅读
  4. Python语言-面向对象

    2024-07-10 02:54:05       68 阅读

热门阅读

  1. UniVue@v1.2.0版本发布

    2024-07-10 02:54:05       24 阅读
  2. 【Lua】元表使用示例

    2024-07-10 02:54:05       25 阅读
  3. 使用 apktool 解包 apk 并重新打包签名

    2024-07-10 02:54:05       20 阅读
  4. Mobile ALOHA前传之VINN, Diffusion Policy和ACT对比

    2024-07-10 02:54:05       23 阅读
  5. React面试题之setState的执行机制

    2024-07-10 02:54:05       23 阅读
  6. 如何控制代码质量

    2024-07-10 02:54:05       22 阅读
  7. C++常用类

    2024-07-10 02:54:05       26 阅读
  8. springboot 与 ipv6

    2024-07-10 02:54:05       21 阅读
  9. UI还原度小技巧之缩放

    2024-07-10 02:54:05       27 阅读
  10. 腾讯centos mysql安装

    2024-07-10 02:54:05       21 阅读