<Window
x:Class="Main"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title=""
Height="130"
Width="200">
<Window.Resources>
<Storyboard
x:Key="StringAnimationStoryboard">
<StringAnimationUsingKeyFrames
AutoReverse="True"
Storyboard.TargetName="MyTextBox"
Storyboard.TargetProperty="Text">
<DiscreteStringKeyFrame Value="" KeyTime="0:0:0" />
<DiscreteStringKeyFrame Value="H" KeyTime="0:0:0.5" />
<DiscreteStringKeyFrame Value="He" KeyTime="0:0:1" />
<DiscreteStringKeyFrame Value="Hel" KeyTime="0:0:1.5" />
<DiscreteStringKeyFrame Value="Hell" KeyTime="0:0:2" />
<DiscreteStringKeyFrame Value="Hello" KeyTime="0:0:2.5" />
<DiscreteStringKeyFrame Value="Hello T" KeyTime="0:0:3" />
<DiscreteStringKeyFrame Value="Hello Th" KeyTime="0:0:3.5" />
<DiscreteStringKeyFrame Value="Hello Thi" KeyTime="0:0:4" />
<DiscreteStringKeyFrame Value="Hello This" KeyTime="0:0:4.5" />
<DiscreteStringKeyFrame Value="Hello This " KeyTime="0:0:5" />
<DiscreteStringKeyFrame Value="Hello This is a test" KeyTime="0:0:5.5" />
</StringAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<DockPanel>
<TextBlock
x:Name="MyTextBox"
DockPanel.Dock="Top"
FontSize="30"
Margin="5" HorizontalAlignment="Center" />
<Button
Content="Start Animation"
Width="100"
Height="20">
<Button.Triggers>
<EventTrigger
RoutedEvent="Button.Click">
<BeginStoryboard
Storyboard="{DynamicResource StringAnimationStoryboard}" />
</EventTrigger>
</Button.Triggers>
</Button>
</DockPanel>
</Window>
|