主要是用到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" //從右往左滾動
創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()