vue-java-tutorials/CSharp/WPFTutorial/WPF-21-StylesandControlTemp.../MainWindow.xaml

42 lines
1.7 KiB
XML

<Window x:Class="WPF_21_StylesandControlTemplates.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"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="Width" Value="100" />
<Setter Property="Height" Value="50" />
<Setter Property="Background" Value="#222222" />
<Setter Property="Foreground" Value="#eee" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#0052c1" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="Green" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<ScrollViewer>
<Rectangle Height="1000" />
</ScrollViewer>
<Button>是什么啊</Button>
</Grid>
</Window>