Mega Code Archive

 
Categories / Silverlight / Graphics
 

The Color property of this rectangles SolidColorBrush is animated

<UserControl x:Class='SilverlightApplication3.MainPage'     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'      d:DesignWidth='640'      d:DesignHeight='480'>     <StackPanel>       <Rectangle Width="100" Height="50" Stroke="Black" StrokeThickness="1"         Grid.Column="4" Grid.Row="1"         HorizontalAlignment="Center" Margin="10">         <Rectangle.Fill>           <SolidColorBrush x:Name="solidColorBrush3" Color="Blue" />         </Rectangle.Fill>       </Rectangle>       <Button Grid.Column="4" Grid.Row="2"         HorizontalAlignment="Center">         Start Animation         <Button.Triggers>           <EventTrigger RoutedEvent="Button.Click">             <BeginStoryboard>               <Storyboard>                 <ColorAnimation Storyboard.TargetName="solidColorBrush3"                   Storyboard.TargetProperty="Color"                   From="Blue" To="#00FF0000" Duration="0:0:10" />               </Storyboard>             </BeginStoryboard>           </EventTrigger>         </Button.Triggers>       </Button>    </StackPanel> </UserControl>