Mega Code Archive

 
Categories / VB.Net Tutorial / WPF
 

Use DiscreteDoubleKeyFrame to switch text

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">     <Grid TextBlock.FontSize="192">         <TextBlock Name="textBoxA" Text="A" Foreground="Red"                    HorizontalAlignment="Center"                    VerticalAlignment="Center" />         <TextBlock Name="here" Text="B" Foreground="Blue"                    Opacity="0"                    HorizontalAlignment="Center"                    VerticalAlignment="Center" />     </Grid>     <Page.Triggers>         <EventTrigger RoutedEvent="Canvas.Loaded">             <BeginStoryboard>                 <Storyboard TargetProperty="Opacity" RepeatBehavior="Forever">                     <DoubleAnimationUsingKeyFrames Storyboard.TargetName="textBoxA">                         <DiscreteDoubleKeyFrame KeyTime="0:0:1" Value="0" />                         <DiscreteDoubleKeyFrame KeyTime="0:0:2" Value="1" />                     </DoubleAnimationUsingKeyFrames>                     <DoubleAnimationUsingKeyFrames Storyboard.TargetName="here">                         <DiscreteDoubleKeyFrame KeyTime="0:0:1" Value="1" />                         <DiscreteDoubleKeyFrame KeyTime="0:0:2" Value="0" />                     </DoubleAnimationUsingKeyFrames>                 </Storyboard>             </BeginStoryboard>         </EventTrigger>     </Page.Triggers> </Page>