[silverlight基础]仿文字连接跑马灯效果-高手绕道
生活随笔
收集整理的這篇文章主要介紹了
[silverlight基础]仿文字连接跑马灯效果-高手绕道
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
運(yùn)行效果如下:
分析示意圖:
代碼:
?1????<Canvas?x:Name="a"?Background="AliceBlue"?MouseEnter="a_MouseEnter"?MouseLeave="a_MouseLeave"?Cursor="Hand"?>
?2????????????<Canvas.Clip>
?3????????????????<RectangleGeometry?RadiusX="0"?RadiusY="0"?Rect="50,50,?300,50"?/>
?4????????????</Canvas.Clip>
?5????????????<Canvas.Triggers>
?6????????????????<EventTrigger?RoutedEvent="Canvas.Loaded"?>
?7????????????????????<BeginStoryboard>
?8????????????????????????<Storyboard?x:Name="animation"?Storyboard.TargetProperty="(Canvas.Left)"?RepeatBehavior="Forever"?>
?9????????????????????????????<DoubleAnimation?Storyboard.TargetName="txt1"?From="50"?To="-500"?Duration="0:0:10"??/>
10????????????????????????????<DoubleAnimation?Storyboard.TargetName="txt2"?From="600"?To="50"?Duration="0:0:10"??/>
11????????????????????????</Storyboard>
12????????????????????</BeginStoryboard>
13????????????????</EventTrigger>
14????????????</Canvas.Triggers>
15????????????<TextBlock?x:Name="txt1"??FontSize="36"?Foreground="Green"?Text="1?2?3?4?5?6?7?8?9?0?a?b?c?d?e?f?"?Canvas.Top="50"?Width="550"?Height="50"/>
16????????????<TextBlock?x:Name="txt2"??FontSize="36"?Foreground="Red"?Text="1?2?3?4?5?6?7?8?9?0?a?b?c?d?e?f?"?Canvas.Top="50"?Width="550"?Height="50"/>
17????????</Canvas>解釋一下:
1.先創(chuàng)建了一個裁減區(qū)(起始坐標(biāo)為50,50,寬度為300,高度為50)--這是必須的,否則超過這個區(qū)域的文字也會顯示出來
2.Storyboard中對二段文字對象的Canvas.Left進(jìn)行了變化,即完成左移
3.RepeatBehavior="Forever"表示這段動畫將一直播放下去(即視覺上好象文字在一起向左滾動)
分析示意圖:
代碼:
?1????<Canvas?x:Name="a"?Background="AliceBlue"?MouseEnter="a_MouseEnter"?MouseLeave="a_MouseLeave"?Cursor="Hand"?>
?2????????????<Canvas.Clip>
?3????????????????<RectangleGeometry?RadiusX="0"?RadiusY="0"?Rect="50,50,?300,50"?/>
?4????????????</Canvas.Clip>
?5????????????<Canvas.Triggers>
?6????????????????<EventTrigger?RoutedEvent="Canvas.Loaded"?>
?7????????????????????<BeginStoryboard>
?8????????????????????????<Storyboard?x:Name="animation"?Storyboard.TargetProperty="(Canvas.Left)"?RepeatBehavior="Forever"?>
?9????????????????????????????<DoubleAnimation?Storyboard.TargetName="txt1"?From="50"?To="-500"?Duration="0:0:10"??/>
10????????????????????????????<DoubleAnimation?Storyboard.TargetName="txt2"?From="600"?To="50"?Duration="0:0:10"??/>
11????????????????????????</Storyboard>
12????????????????????</BeginStoryboard>
13????????????????</EventTrigger>
14????????????</Canvas.Triggers>
15????????????<TextBlock?x:Name="txt1"??FontSize="36"?Foreground="Green"?Text="1?2?3?4?5?6?7?8?9?0?a?b?c?d?e?f?"?Canvas.Top="50"?Width="550"?Height="50"/>
16????????????<TextBlock?x:Name="txt2"??FontSize="36"?Foreground="Red"?Text="1?2?3?4?5?6?7?8?9?0?a?b?c?d?e?f?"?Canvas.Top="50"?Width="550"?Height="50"/>
17????????</Canvas>解釋一下:
1.先創(chuàng)建了一個裁減區(qū)(起始坐標(biāo)為50,50,寬度為300,高度為50)--這是必須的,否則超過這個區(qū)域的文字也會顯示出來
2.Storyboard中對二段文字對象的Canvas.Left進(jìn)行了變化,即完成左移
3.RepeatBehavior="Forever"表示這段動畫將一直播放下去(即視覺上好象文字在一起向左滾動)
轉(zhuǎn)載于:https://www.cnblogs.com/yjmyzz/archive/2009/09/09/1563259.html
總結(jié)
以上是生活随笔為你收集整理的[silverlight基础]仿文字连接跑马灯效果-高手绕道的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 学习《Building Applicat
- 下一篇: 随便写写(8)