您的位置:首页 > 科技 > IT业 > WPF界面设计-更改按钮样式 自定义字体图标

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

2024/10/6 18:21:01 来源:https://blog.csdn.net/weixin_67244432/article/details/140298679  浏览:    关键词: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>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com