代码改变世界

wpf 炫彩动画效果简单实例

2011-07-01 13:26  观海看云  阅读(1939)  评论(0编辑  收藏  举报

<Button >
<Button.Background>
<LinearGradientBrush>
<GradientStop Color="Blue" Offset="0"></GradientStop>
<GradientStop Color="Black" Offset="0.5"></GradientStop>
<GradientStop Color="Blue" Offset="1"></GradientStop>
</LinearGradientBrush>
</Button.Background>
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard >
<ColorAnimation Storyboard.TargetProperty="Background.GradientStops[1].Color" From="Black" To="White" Duration="0:0:2" AutoReverse="True" RepeatBehavior="Forever">
</ColorAnimation>
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Background.GradientStops[1].Offset"
From
="0" To="1" Duration="0:0:2" AutoReverse="True" RepeatBehavior="Forever">
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Button.Triggers>
</Button>

效果图变化:

  ==》