wpf 有图片的按键样式

<Style x:Key="BtnBackgroundIconCustomDialogStyle" TargetType="{x:Type Button}">

<Setter Property="FocusVisualStyle" Value="{x:Null}" />

<Setter Property="SnapsToDevicePixels" Value="true" />

<Setter Property="Width" Value="150" />

<Setter Property="Height" Value="40" />

<Setter Property="BorderThickness" Value="0" />

<Setter Property="FontWeight" Value="Normal" />

<Setter Property="FontSize" Value="17" />

<Setter Property="Foreground" Value="White" />

<Setter Property="Background" Value="#049AFF" />

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type Button}">

<Border BorderThickness="{TemplateBinding BorderThickness}" Width="{TemplateBinding Width}" CornerRadius="4" Background="{TemplateBinding Background}" Effect="{TemplateBinding Effect}" HorizontalAlignment="Center">

<Grid HorizontalAlignment="Center">

<Grid.ColumnDefinitions>

<ColumnDefinition Width="Auto" />

<ColumnDefinition Width="*" />

</Grid.ColumnDefinitions>

<Image Grid.Column="0" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Tag}" Width="14" Height="14" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" />

<TextBlock Grid.Column="1" Text="{TemplateBinding Content}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" TextAlignment="Center" />

</Grid>

</Border>

<ControlTemplate.Triggers>

<Trigger Property="IsFocused" Value="True">

<Setter Property="Background" Value="#2B6FD5" />

<Setter Property="Foreground" Value="#fff" />

</Trigger>

<Trigger Property="IsMouseOver" Value="True">

<Setter Property="Background" Value="#2B6FD5" />

<Setter Property="Foreground" Value="#fff" />

</Trigger>

</ControlTemplate.Triggers>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

相关推荐
夏梦春蝉32 分钟前
ES6从入门到精通:模块化
前端·ecmascript·es6
拓端研究室1 小时前
视频讲解:门槛效应模型Threshold Effect分析数字金融指数与消费结构数据
前端·算法
工一木子2 小时前
URL时间戳参数深度解析:缓存破坏与前端优化的前世今生
前端·缓存
半点寒12W4 小时前
微信小程序实现路由拦截的方法
前端
某公司摸鱼前端5 小时前
uniapp socket 封装 (可拿去直接用)
前端·javascript·websocket·uni-app
要加油哦~5 小时前
vue | 插件 | 移动文件的插件 —— move-file-cli 插件 的安装与使用
前端·javascript·vue.js
小林学习编程5 小时前
Springboot + vue + uni-app小程序web端全套家具商场
前端·vue.js·spring boot
柳鲲鹏5 小时前
WINDOWS最快布署WEB服务器:apache2
服务器·前端·windows
weixin-a153003083166 小时前
【playwright篇】教程(十七)[html元素知识]
java·前端·html
ai小鬼头6 小时前
AIStarter最新版怎么卸载AI项目?一键删除操作指南(附路径设置技巧)
前端·后端·github