<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Microsoft.Samples.Graphics.RectangleExample" WindowTitle="Example"> <Canvas> <Grid Margin="5" TextBlock.FontSize="16"> <TextBlock Margin="10" VerticalAlignment="Center">Exclude</TextBlock> </Grid> </Canvas> </Page>
Windows Presentation Foundation
Animates the position of the TextEffect
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowTitle="TextEffect Sample" Background="SteelBlue"> <StackPanel Margin="40"> <Border Name="TextBorder" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock FontSize="60" Margin="50" Foreground="White"> Windows Vista <TextBlock.Triggers> <EventTrigger RoutedEvent="TextBlock.Loaded"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard> <ParallelTimeline RepeatBehavior="Forever"> <Int32AnimationUsingKeyFrames Storyboard.TargetName="MyTextEffect" Storyboard.TargetProperty="PositionStart" Duration="0:0:13" AutoReverse="True" RepeatBehavior="Forever"> <Int32AnimationUsingKeyFrames.KeyFrames> <DiscreteInt32KeyFrame Value="0" KeyTime="0:0:0" /> <DiscreteInt32KeyFrame Value="1" KeyTime="0:0:1" /> <DiscreteInt32KeyFrame Value="2" KeyTime="0:0:2" /> <DiscreteInt32KeyFrame Value="3" KeyTime="0:0:3" /> <DiscreteInt32KeyFrame Value="4" KeyTime="0:0:4" /> <DiscreteInt32KeyFrame Value="5" KeyTime="0:0:5" /> <DiscreteInt32KeyFrame Value="6" KeyTime="0:0:6" /> <DiscreteInt32KeyFrame Value="7" KeyTime="0:0:7" /> <DiscreteInt32KeyFrame Value="8" KeyTime="0:0:8" /> <DiscreteInt32KeyFrame Value="9" KeyTime="0:0:9" /> <DiscreteInt32KeyFrame Value="10" KeyTime="0:0:10" /> <DiscreteInt32KeyFrame Value="11" KeyTime="0:0:11" /> <DiscreteInt32KeyFrame Value="12" KeyTime="0:0:12" /> </Int32AnimationUsingKeyFrames.KeyFrames> </Int32AnimationUsingKeyFrames> </ParallelTimeline> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </TextBlock.Triggers> </TextBlock> </Border> </StackPanel> </Page>
Animates the horizontal center of the RotateTransform applied to the TextEffect
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowTitle="TextEffect Sample" Background="SteelBlue"> <StackPanel Margin="40"> <Border Name="TextBorder" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock FontSize="60" Margin="50" Foreground="White"> Windows Vista <TextBlock.Triggers> <EventTrigger RoutedEvent="TextBlock.Loaded"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard> <ParallelTimeline RepeatBehavior="Forever"> <DoubleAnimation From="30" To="370" Duration="00:00:13" RepeatBehavior="Forever" AutoReverse="True" Storyboard.TargetName="TextEffectRotateTransform" Storyboard.TargetProperty="CenterX" /> </ParallelTimeline> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </TextBlock.Triggers> </TextBlock> </Border> </StackPanel> </Page>
TextEffect to animate
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowTitle="TextEffect Sample" Background="SteelBlue"> <StackPanel Margin="40"> <Border Name="TextBorder" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock FontSize="60" Margin="50" Foreground="White"> Windows Vista <TextBlock.TextEffects> <TextEffect PositionCount="1" x:Name="MyTextEffect"> <TextEffect.Transform> <RotateTransform x:Name="TextEffectRotateTransform" Angle="0" CenterX="10" CenterY="10" /> </TextEffect.Transform> </TextEffect> </TextBlock.TextEffects> </TextBlock> </Border> </StackPanel> </Page>
Animates the text block's width
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Microsoft.Samples.Graphics.RectangleExample" WindowTitle="Example"> <Canvas> <TextBlock Name="MyWipedText" Margin="20" Width="480" Height="100" FontSize="48" FontWeight="Bold" Foreground="Maroon"> This is wiped text <TextBlock.Triggers> <EventTrigger RoutedEvent="TextBlock.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="MyWipedText" Storyboard.TargetProperty="(TextBlock.Width)" To="0.0" Duration="0:0:10" AutoReverse="True" RepeatBehavior="Forever" /> </Storyboard> </BeginStoryboard> </EventTrigger> </TextBlock.Triggers> </TextBlock> </Canvas> </Page>
Animates the text block's opacity(fading text)
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Microsoft.Samples.Graphics.RectangleExample" WindowTitle="Example"> <Canvas> <TextBlock Name="MyFadingText" Margin="20" Width="640" Height="100" FontSize="48" FontWeight="Bold" Foreground="Maroon"> This is fading text <TextBlock.Triggers> <EventTrigger RoutedEvent="TextBlock.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="MyFadingText" Storyboard.TargetProperty="(TextBlock.Opacity)" From="1.0" To="0.0" Duration="0:0:5" AutoReverse="True" RepeatBehavior="Forever" /> </Storyboard> </BeginStoryboard> </EventTrigger> </TextBlock.Triggers> </TextBlock> </Canvas> </Page>
Animates the text block's color
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Microsoft.Samples.Graphics.RectangleExample" WindowTitle="Example"> <Canvas> <TextBlock Name="MyChangingColorText" Margin="20" Width="640" Height="100" FontSize="48" FontWeight="Bold"> This is changing color text <TextBlock.Foreground> <SolidColorBrush x:Name="MySolidColorBrush" Color="Maroon" /> </TextBlock.Foreground> <TextBlock.Triggers> <EventTrigger RoutedEvent="TextBlock.Loaded"> <BeginStoryboard> <Storyboard> <ColorAnimation Storyboard.TargetName="MySolidColorBrush" Storyboard.TargetProperty="Color" From="DarkOrange" To="SteelBlue" Duration="0:0:5" AutoReverse="True" RepeatBehavior="Forever" /> </Storyboard> </BeginStoryboard> </EventTrigger> </TextBlock.Triggers> </TextBlock> </Canvas> </Page>