Mega Code Archive

 
Categories / C# / WPF
 

Animate Opacity

<Window x:Class="Animation.AnimateVisual"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="AnimateVisualBrush" Height="300" Width="300" Background="LightGoldenrodYellow">     <Grid>       <Grid.RowDefinitions>         <RowDefinition></RowDefinition>         <RowDefinition></RowDefinition>       </Grid.RowDefinitions>       <Button Name="visual" HorizontalAlignment="Center" VerticalAlignment="Center">         <Button.Content>Test</Button.Content>         <Button.Triggers>           <EventTrigger RoutedEvent="Button.Click">             <BeginStoryboard>               <Storyboard  RepeatBehavior="Forever">                 <DoubleAnimation Storyboard.TargetName="rectangle"                                  Storyboard.TargetProperty="Opacity"                                  To="0.1" Duration="0:0:4" AutoReverse="True"></DoubleAnimation>               </Storyboard>             </BeginStoryboard>           </EventTrigger>         </Button.Triggers>       </Button>              <Rectangle Grid.Row="1" Name="rectangle" Width="100" Stretch="Uniform" ClipToBounds="False" RenderTransformOrigin="0.5,0.5">         <Rectangle.Fill>           <VisualBrush Visual="{Binding ElementName=visual}">           </VisualBrush>         </Rectangle.Fill>       </Rectangle>     </Grid>   </Window>