45 lines
2.4 KiB
XML
45 lines
2.4 KiB
XML
<Window x:Class="_5_17._3._4使用动画的触发器.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>
|
|
<ControlTemplate x:Key="ButtonControlTemplate" TargetType="{x:Type Button}">
|
|
<Border BorderBrush="Orange" BorderThickness="3" CornerRadius="2" Background="Red"
|
|
TextBlock.Foreground="Wheat" Name="Border">
|
|
<Grid>
|
|
<Rectangle Name="FocusCue" Visibility="Hidden" Stroke="Black" StrokeThickness="1"
|
|
StrokeDashArray="1 2" SnapsToDevicePixels="True" />
|
|
<ContentPresenter RecognizesAccessKey="True" Margin="{TemplateBinding Padding}" />
|
|
</Grid>
|
|
</Border>
|
|
|
|
<ControlTemplate.Triggers>
|
|
<EventTrigger RoutedEvent="MouseEnter">
|
|
<BeginStoryboard>
|
|
<Storyboard>
|
|
<ColorAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="Background.Color"
|
|
To="Blue" Duration="0:0:1" AutoReverse="True" RepeatBehavior="Forever" />
|
|
</Storyboard>
|
|
</BeginStoryboard>
|
|
</EventTrigger>
|
|
<EventTrigger RoutedEvent="MouseLeave">
|
|
<BeginStoryboard>
|
|
<Storyboard>
|
|
<ColorAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="Background.Color"
|
|
Duration="0:0:3" />
|
|
</Storyboard>
|
|
</BeginStoryboard>
|
|
</EventTrigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Window.Resources>
|
|
|
|
<StackPanel>
|
|
<Button Template="{StaticResource ButtonControlTemplate}" Margin="10" Padding="15 5">按钮</Button>
|
|
<Button Template="{StaticResource GradientButtonTemplate}"> 111 </Button>
|
|
<Button Template="{StaticResource GradientButtonTemplate}" IsEnabled="False"> 111 </Button>
|
|
</StackPanel>
|
|
</Window> |