自定义按钮模板以及设置触发器
<Window x:Class="WPF_Study_Solution.Window4"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPF_Study_Solution"
mc:Ignorable="d"
Title="Window4" Height="450" Width="800">
<Grid>
<Button Width="300" Height="200" Content="自定义按钮1" Background="Red" FontSize="30" Foreground="White">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="boder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="4" CornerRadius="40">
<TextBlock x:Name="txtContent" Text="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="boder" Property="Background" Value="Black"/>
<Setter TargetName="txtContent" Property="FontSize" Value="35"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="boder" Property="Background" Value="Blue"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</Window>