Silverlight加载界面实现方法解析

开发 开发工具
Silverlight加载界面的实现被我们总共分为了9个步骤。在这里将会对这几个步骤一一的做出解释,以方便大家理解。

Silverlight加载界面的实现方法在这篇文章中将会为大家详细介绍。希望对一些又需要的朋友men有些帮助。在一个解决方案中,有SplashScreenSourceweb和SplashScreenSource两个项目。#t#

要往silverlight中加入自定义装载界面,需要加入到SplashScreenSourceweb项目中,这样,自定义装载界面就不会和其它xaml文件一起打包到silverlight程序包中。

Silverlight加载界面步骤如下:

1.右击silverlightapplicationweb项目,选择属性,选择启动选项,把SplashScreenSourceTestPage.html设为启动页面。

2.右击silverlightapplicationweb项目,选择添加新项,选择添加一个Silverlight JScript 页,命名为SplashScreen.xaml。

3.打开SplashScreen.xaml,换成如下代码:

 

  1. < Canvas 
  2. xmlns="http://schemas.microsoft.
    com/client/2007"
       
  3. xmlns:x="http://schemas.
    microsoft.com/winfx/2006/xaml"
       
  4. x:Name="parentCanvas"   
  5. Width="850" 
  6. Height="600" 
  7. Background="OldLace" 
  8. > 
  9. < Canvas Canvas.Top="228.834" 
    Canvas.Left="246.329" Width="357" 
    Height="31.379"> 
  10. < Rectangle Width="27.545" 
    Height="1" x:Name="uxProgress" 
    Canvas.Top="29.545" Canvas.Left="1.4"> 
  11. < Rectangle.RenderTransform> 
  12. < TransformGroup> 
  13. < ScaleTransform x:Name="uxProgressBar" 
    ScaleX="1" ScaleY="0"/> 
  14. < SkewTransform AngleX="0" AngleY="0"/> 
  15. < RotateTransform Angle="270"/> 
  16. < TranslateTransform X="0" Y="0"/> 
  17. < /TransformGroup> 
  18. < /Rectangle.RenderTransform> 
  19. < Rectangle.Fill> 
  20. < LinearGradientBrush EndPoint=
    "1,0.5" StartPoint="0,0.5"> 
  21. < GradientStop Color="#FFFFFFFF" 
    Offset="1"/> 
  22. < GradientStop Color="#FFFFFFFF" 
    Offset="0"/> 
  23. < GradientStop Color="#FF2975D0"
     Offset="0.28"/> 
  24. < GradientStop Color="#FF2975D0"
     Offset="0.72"/> 
  25. < /LinearGradientBrush> 
  26. < /Rectangle.Fill> 
  27. < /Rectangle> 
  28. < TextBlock x:Name="uxStatus" Height="25" 
    Canvas.Left="125" Text="Loading..." 
    TextWrapping="Wrap" Canvas.Top="4.16"/> 
  29. < Path Width="356.85" Height="1" 
    Fill="#FF3A3A3A" Stretch="Fill" 
    Stroke="#FF000000" Canvas.Top="0" 
    Data="M0,170.5 L356.84209,170.5" 
    Opacity="0.35"/> 
  30. < Path Width="1.662" Height="29.03" 
    Fill="#FF3A3A3A" Stretch="Fill" 
    Stroke="#FF000000" Canvas.Top="0.48" 
    Canvas.Left="0.2" Data="M360,168 L360,0" 
    Opacity="0.35" /> 
  31. < Path Width="357.84" Height="1"
     Fill="#FF3A3A3A" Stretch="Fill" 
    Stroke="#FF000000" Canvas.Top="29" 
    Data="M0,170.5 L356.84209,170.5" Opacity="0.35"/> 
  32. < Path Width="358.85" Height="1" Fill="#FFA2A2A2" 
    Stretch="Fill" Stroke="#FF000000" Canvas.Top="30" 
    Data="M0,170.5 L356.84209,170.5" Opacity="0.25"/> 
  33. < Path Width="1.662" Height="30" Fill="#FF3A3A3A" 
    Stretch="Fill" Stroke="#FF000000" 
    Canvas.Left="356.01" Data="M360,168 L360,0" 
    Opacity="0.35" Canvas.Top="-0.498"/> 
  34. < Path Width="1" Height="31" Fill="#FFA2A2A2" 
    Stretch="Fill" Stroke="#FF000000" 
    Canvas.Left="357.333" Data="M360,168 L360,0" 
    Opacity="0.245" Canvas.Top="-0.498" />   
  35. < /Canvas> 
  36. < /Canvas> 

 


Silverlight加载界面4.打开SplashScreenSourceTestPage.html,把代码

 

  1. < param name="source" 
    value="ClientBin/Splash
    ScreenSource.xap"
    /> 

改成

 

  1. < param name="source" 
    value="SplashScreenSource.xap"/>  

 

5.在解决方案资源管理器中,把ClientBin目录下的SplashScreenSource.xap拖到SplashScreenSourceWeb根目录下。

6.打开SplashScreenSourceTestPage.html,加入如下代码:

 

  1. < param name="splashscreensource" 
    value="SplashScreen.xaml"/> 
  2. < param name="onSourceDownload
    ProgressChanged"
     value=
    "onSourceDownloadProgressChanged" /> 

 

Silverlight加载界面7.打开SplashScreen.js,输入以下代码:

 

  1. function onSourceDownload
    ProgressChanged(sender, eventArgs)  
  2. {  
  3. sender.findName("uxStatus").
    Text
     = "Loading: " + Math.
    round((eventArgs.progress * 
    1000)) / 10 + "%";  
  4. sender.findName("uxProgressBar").
    ScaleY
     = eventArgs.progress * 356;  

 

8.打开SplashScreenSourceTestPage.html,加入以下代码:

 

  1. < script type="text/javascript" 
    src="splashscreen.js">< /script> 

 

9.运行Silverlight加载界面!

责任编辑:曹凯 来源: 百度博客
相关推荐

2009-12-31 11:23:23

Silverlight

2009-12-30 15:42:08

Silverlight

2009-12-30 17:19:09

Silverlight

2010-01-04 17:29:00

Silverlight

2009-12-30 13:51:43

Silverlight

2009-12-30 15:26:02

Silverlight

2009-09-28 10:35:45

Silverlight

2010-01-04 16:30:06

Silverlight

2009-12-30 14:10:27

Silverlight

2009-12-30 17:44:22

Silverlight

2009-12-29 15:38:17

silverlight

2009-12-30 15:08:04

Silverlight

2009-12-29 16:36:47

Silverlight

2009-10-27 10:28:33

Silverlight

2009-12-30 18:28:56

Silverlight

2009-12-31 16:50:02

Silverlight

2009-12-31 14:25:19

Silverlight

2009-06-09 13:21:32

Oracle Data实现

2009-12-28 17:33:19

WPF视频音频

2009-12-31 16:18:44

Silverlight
点赞
收藏

51CTO技术栈公众号