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>

相关推荐
佛系打工仔2 小时前
绘制K线第二章:背景网格绘制
android·前端·架构
明天好,会的4 小时前
分形生成实验(五):人机协同破局--30万token揭示Actix-web状态管理的微妙边界
运维·服务器·前端
C_心欲无痕5 小时前
nginx - alias 和 root 的区别详解
运维·前端·nginx
我是苏苏7 小时前
Web开发:C#通过ProcessStartInfo动态调用执行Python脚本
java·服务器·前端
无羡仙7 小时前
Vue插槽
前端·vue.js
用户6387994773058 小时前
每组件(Per-Component)与集中式(Centralized)i18n
前端·javascript
SsunmdayKT8 小时前
React + Ts eslint配置
前端
开始学java8 小时前
useEffect 空依赖 + 定时器 = 闭包陷阱?count 永远停在 1 的坑我踩透了
前端
zerosrat8 小时前
从零实现 React Native(2): 跨平台支持
前端·react native