码迷,mamicode.com
首页 > Web开发 > 详细

Silverlight实现滚动文字

时间:2015-01-07 14:59:00      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:silverlight   文字滚动   xaml   

主要是用到DoubleAnimation 标签:

<Canvas x:Name="c1" Margin="2,25,2,2">
            <Canvas.Triggers>
                <EventTrigger RoutedEvent="Canvas.Loaded" >
                    <BeginStoryboard>
                        <Storyboard x:Name="animation" RepeatBehavior="Forever" >
                            <DoubleAnimation Storyboard.TargetName="ScrollingUp"                    
                                             Storyboard.TargetProperty="(Canvas.Left)" From="1024" To="0" Duration="0:0:15"  />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Canvas.Triggers>
            <TextBlock x:Name="ScrollingUp" FontWeight="Bold" Foreground="Red"  FontSize="12" TextWrapping="Wrap" Height="113">
                滚动文字
            </TextBlock>
        </Canvas>
 

这里是滚动文字的代码,主要的就是StoryBoard里的属性设置:

Storyboard.TargetProperty="(Canvas.Top)" From="100" To="0" Duration="0:0:10"

同理,其他方向如下设置即可:

Storyboard.TargetProperty="(Canvas.Top)" From="0" To="100" Duration="0:0:10"   //从上往下滚动

Storyboard.TargetProperty="(Canvas.Left)" From="0" To="100" Duration="0:0:10"   //从左往右滚动

Storyboard.TargetProperty="(Canvas.Left)" From="100" To="0" Duration="0:0:10"   //从右往左滚动

Silverlight实现滚动文字

标签:silverlight   文字滚动   xaml   

原文地址:http://blog.csdn.net/mutou965175859/article/details/42492265

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