Mega Code Archive

 
Categories / VB.Net Tutorial / WPF
 

Use ColorAnimation to animate background

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"       HorizontalAlignment="Stretch" VerticalAlignment="Stretch">          <Button Background="Red" VerticalAlignment="Center" HorizontalAlignment="Center" Content="AAA">       <Button.Triggers>         <EventTrigger RoutedEvent="Button.Loaded">           <BeginStoryboard>             <Storyboard>               <ParallelTimeline Duration="0:0:5">                                    <ColorAnimation BeginTime="0:0:2" Duration="0:0:1"                                 Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)"                                 From="Red" To="Yellow" AutoReverse="True"                                 RepeatBehavior="Forever" />                    </ParallelTimeline>             </Storyboard>           </BeginStoryboard>         </EventTrigger>       </Button.Triggers>     </Button> </Page>