码迷,mamicode.com
首页 > Windows程序 > 详细

WPF 滚动文本

时间:2015-02-27 16:46:49      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:

<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>

 

WPF 滚动文本

标签:

原文地址:http://www.cnblogs.com/pengzhong/p/WPFEasingText.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!