zoukankan      html  css  js  c++  java
  • 豆瓣电台WP7客户端 开发记录7

    由于歌曲名称可能超过屏幕宽度而显示不下,所以当歌曲名称长度大于屏幕宽度的时候滚动显示。

     这里主要用storyboard来完成,主要是silverlight的知识了。

     1                 <Canvas>

     2                     <Canvas.Resources>
     3                         <Storyboard x:Name="sb">
     4                             <DoubleAnimation x:Name="animation"
     5                             Storyboard.TargetProperty="(Canvas.Left)"
     6                             Storyboard.TargetName="SongName"
     7                             Duration="0:0:9"
     8                             RepeatBehavior="Forever" />
     9                         </Storyboard>
    10                     </Canvas.Resources>
    11                 <TextBlock  x:Name="SongName" FontSize="24"   HorizontalAlignment="Center" Margin="0,15,0,0" />

    12                 </Canvas> 

    cs: 1  /// <summary>

     2         /// 歌曲名称滚动
     3         /// </summary>
     4         private void SongNameMarquee()
     5         {
     6             this.sb.Stop();
     7             double sysWidth = System.Windows.Application.Current.Host.Content.ActualWidth;//屏幕宽度
     8             if (sysWidth <= this.SongName.ActualWidth)
     9             {
    10                 animation.From = sysWidth;
    11                 animation.To = -this.SongName.ActualWidth - (sysWidth - 360/ 2;//360为Canvas宽度
    12                 this.sb.Begin();
    13             }
    14             else
    15             {//canvas居中
    16                 this.SongName.SetValue(Canvas.LeftProperty, 180-this.SongName.ActualWidth/2);
    17             }
    18 
    19         }

     主要是计算几个点麻烦点 其他没什么。

    QQ群:1022985150 VX:kklldog 一起探讨学习.NET技术
    作者:Agile.Zhou(kklldog)
    出处:http://www.cnblogs.com/kklldog/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    解决:Could not resolve archetype org.apache.maven.archetypes
    Spring MVC配置MyBatis输出SQL
    Spring集成MyBatis 通用Mapper以及 pagehelper分页插件
    关于SpringMVC或Struts2接受参数接收不到的原因
    配置quartz启动时就执行一次
    ajaxFileUpload进行文件上传时,总是进入error
    spring mvc注入配置文件里的属性
    java中将一个文件夹下所有的文件压缩成一个文件
    flume failed to start agent because dependencies were not found in classpath
    ubuntu不能安装pip unable to install pip in unbuntu
  • 原文地址:https://www.cnblogs.com/kklldog/p/2176806.html
Copyright © 2011-2022 走看看