3-WPF-Order/5-WPF样式和行为-7简单触发器/MainWindow.xaml

40 lines
1.9 KiB
Plaintext
Raw Normal View History

2025-01-13 21:05:01 +08:00
<Window x:Class="_5_WPF样式和行为_7简单触发器.MainWindow"
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"
mc:Ignorable="d"
Icon="public/003540AH4M72.jpg" Title="_5_WPF样式和行为_7简单触发器" Height="450" Width="800">
<Window.Resources>
<Style x:Key="BigFontButton">
<Style.Setters>
<Setter Property="Control.FontFamily" Value="Times New Roman" />
<Setter Property="Control.FontSize" Value="18" />
</Style.Setters>
<Style.Triggers>
<!-- 获取焦点或者使用tab键 -->
<Trigger Property="Control.IsFocused" Value="True">
<Setter Property="Control.Foreground" Value="DarkRed" />
<Setter Property="Control.Background" Value="SpringGreen" />
<Setter Property="Control.FontSize" Value="20" />
<Setter Property="Control.FontWeight" Value="ExtraBold" />
</Trigger>
<Trigger Property="Control.IsMouseOver" Value="True">
<Setter Property="Control.Foreground" Value="OrangeRed" />
<Setter Property="Control.FontWeight" Value="Light" />
</Trigger>
<Trigger Property="Button.IsPressed" Value="True">
<Setter Property="Control.Foreground" Value="SkyBlue" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<Button Padding="15 5 " Margin="10" Style="{StaticResource BigFontButton}">o(* ̄︶ ̄*)o</Button>
</StackPanel>
</Window>