zoukankan      html  css  js  c++  java
  • Silverlight 中实现 marquee 的效果 滚动显示 火麒

    <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" BorderThickness="0" Height="36">
                    <Canvas Loaded="MarqueeControl_Loaded" Width="592" HorizontalAlignment="Left">
                                  <Canvas.Resources>
                            <Storyboard x:Name="sb">
                                <DoubleAnimation x:Name="da" BeginTime="00:00:02" Storyboard.TargetName="txtLorem" Storyboard.TargetProperty="(Canvas.Left)" From="0" RepeatBehavior="Forever"/>
                            </Storyboard>
                        </Canvas.Resources>
                        <TextBlock x:Name="txtLorem" Width="596" Height="33" Text="滚动文字内容..."/>
                    </Canvas>
    </ScrollViewer>

    void MarqueeControl_Loaded(object sender, RoutedEventArgs e)
            {
                var canvas = sender as Canvas;
                if (txtLorem.ActualWidth <= canvas.Width) return;
                const double speed = 50;
                da.To = -txtLorem.ActualWidth;
                da.Duration = new Duration(TimeSpan.FromSeconds(txtLorem.ActualWidth / speed));
                sb.Begin();
            }

  • 相关阅读:
    集合框架
    5.异常
    接口小结
    多态(3)面向对象的三大特征之三
    面向对象编程(1)继承
    第五章博客
    《MySQL数据库》MySQL集群工具mycat安装
    《MySQL数据库》MySQL分区表
    《MySQL数据库》MySQL读写分离(Atlas)
    《Redis内存数据库》Redis数据类型和基本操作
  • 原文地址:https://www.cnblogs.com/firekylin/p/2025009.html
Copyright © 2011-2022 走看看