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>

相关推荐
人工智能训练师7 小时前
Ubuntu22.04如何安装新版本的Node.js和npm
linux·运维·前端·人工智能·ubuntu·npm·node.js
Seveny077 小时前
pnpm相对于npm,yarn的优势
前端·npm·node.js
yddddddy8 小时前
css的基本知识
前端·css
昔人'8 小时前
css `lh`单位
前端·css
Nan_Shu_6149 小时前
Web前端面试题(2)
前端
知识分享小能手9 小时前
React学习教程,从入门到精通,React 组件核心语法知识点详解(类组件体系)(19)
前端·javascript·vue.js·学习·react.js·react·anti-design-vue
蚂蚁RichLab前端团队10 小时前
🚀🚀🚀 RichLab - 花呗前端团队招贤纳士 - 【转岗/内推/社招】
前端·javascript·人工智能
孩子 你要相信光11 小时前
css之一个元素可以同时应用多个动画效果
前端·css
玉面小君11 小时前
从 WPF 到 Avalonia 的迁移系列实战篇6:Trigger、MultiTrigger、DataTrigger 的迁移
wpf·avalonia
huangql52011 小时前
npm 发布流程——从创建组件到发布到 npm 仓库
前端·npm·node.js