当前位置:   article > 正文

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

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

一、下载图标文件 



iconfont-阿里巴巴矢量图标库

二、xaml界面代码编辑

文件结构

           对应的图标代码

Fonts/#iconfont   对应文件位置

  1. <Window.Resources>
  2. <ControlTemplate TargetType="Button" x:Key="CloseButtonTemplate">
  3. <Grid Background="Transparent" Name="back">
  4. <TextBlock Text="&#xe653;" FontFamily="Fonts/#iconfont" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14"/>
  5. </Grid>
  6. <ControlTemplate.Triggers>
  7. <Trigger Property="IsMouseOver" Value="True">
  8. <Setter Property="Background" Value="red" TargetName="back"/>
  9. </Trigger>
  10. </ControlTemplate.Triggers>
  11. </ControlTemplate>
  12. </Window.Resources>
  1. <Grid ShowGridLines="True">
  2. <Grid.RowDefinitions>
  3. <RowDefinition Height="30" />
  4. <RowDefinition Height="30"/>
  5. <RowDefinition Height="50"/>
  6. </Grid.RowDefinitions>
  7. <Button HorizontalAlignment="Right" Content="X" Margin="0,0,0,0" Width="60" Height="30" BorderThickness="0"
  8. Template="{StaticResource CloseButtonTemplate}"/>
  9. </Grid>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/825833
推荐阅读
相关标签
  

闽ICP备14008679号