标签:
<Window x:Class="MyAnimationDemo.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="115" Width="700"> <Window.Resources> <Style TargetType="TextBlock"> <Setter Property="FontSize" Value="20"/> </Style> </Window.Resources> <Grid> <Canvas> <StackPanel Name="TextPanel" Canvas.Top="0"> <StackPanel.Triggers> <EventTrigger RoutedEvent="Control.Loaded"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard> <!--<DoubleAnimation Storyboard.TargetName="TextPanel" Storyboard.TargetProperty="(Canvas.Top)" Duration="0:0:2" To="-76" RepeatBehavior="Forever"/>--> <!--Storyboard.TargetProperty添加附加属性,需要加括号--> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TextPanel" Storyboard.TargetProperty="(Canvas.Top)" RepeatBehavior="Forever"> <EasingDoubleKeyFrame KeyTime="0:0:2" Value="0"/> <EasingDoubleKeyFrame KeyTime="0:0:3" Value="-76"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </StackPanel.Triggers> <TextBlock Text="骑牛远远过前村,吹笛风斜隔垄闻。多少长安名利客,机关用尽不如君。"/> <TextBlock Text="春有百花秋有月,夏有凉风冬有雪;若无闲事挂心头,便是人间好时节。"/> <TextBlock Text="一东一西陇头水,一聚一散天边霞。一来一去道上客,一颠一倒池中麻。"/> <TextBlock Text="骑牛远远过前村,吹笛风斜隔垄闻。多少长安名利客,机关用尽不如君。"/> <TextBlock Text="春有百花秋有月,夏有凉风冬有雪;若无闲事挂心头,便是人间好时节。"/> <TextBlock Text="一东一西陇头水,一聚一散天边霞。一来一去道上客,一颠一倒池中麻。"/> </StackPanel> </Canvas> </Grid> </Window>
标签:
原文地址:http://www.cnblogs.com/pengzhong/p/WPFEasingText.html