I saw the light Silverlight Tip: Splash screen issues. - Alexey Zakharov's Blog

Silverlight Tip: Splash screen issues.

Today I worked on silverlight splash screen for our site and found that documentation about splash screen is very poor and cause many misunderstandings. In this post i'll try to make some of them disappear. =)

Because of silverlight splash screen is managed with JavaScript many people thinks that they cannot use layout controls (grid, stackpanel etc) which appeared only in silverlight 2.0.  As I found out this is not true. You can use them, but if you open your splashscreen.xaml in blend you will get some errors, because all xaml files inside web project are recognized as silverlight 1.0 files.

It is very useful to use grid for building splash screen, because your can easily ceter it with this control. With canvas centering of your splash screen will be little javascript nightmare =)

Here i will give u simple example of splash screen, which consists of centered textblock, where i will show current download progress.

SplashScreen.xaml:

   1: <Grid
   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
   4:     >
   5:     <Grid x:Name="LayoutRoot" Background="{x:Null}" Width="200" Height="200">
   6:         <TextBlock x:Name="ProgressText" Margin="0,0,0,0" Text="0%" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Trebuchet MS" FontSize="24" FontWeight="Bold" Opacity="1" Foreground="#FF716770"/>
   7:     </Grid>
   8: </Grid>

SilverlightTestPage.aspx:

   1: <head runat="server">
   2:     <title>SilverlightApplication</title>
   3:         <script type="text/javascript">
   1:  
   2:             function OnSourceDownloadProgressChanged(sender, args) {
   3:                 var root = sender.get_element().content;
   4:                 var progress = Math.round((args.get_progress() * 100))
   5:                 root.findName("ProgressText").Text = progress + "%";
   6:             }
   7:         
</script>
   4: </head>
   5: <body style="height:100%;margin:0;">
   6:     <form id="form1" runat="server" style="height:100%;">
   7:         <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
   8:         <div  style="height:100%;">
   9:             <asp:Silverlight ID="Xaml1" runat="server" 
  10:                 SplashScreenSource="~/MyApp.xaml" OnPluginSourceDownloadProgressChanged="OnSourceDownloadProgressChanged"
  11:                 Source="~/ClientBin/SilverlightApplication.xap" MinimumVersion="2.0.31005.0" Width="100%" Height="100%" />
  12:         </div>
  13:     </form>
  14: </body>
Published Saturday, December 13, 2008 2:34 PM by brainbox

Comments

# 2008 December 15 - Links for today &laquo; My (almost) Daily Links

Pingback from  2008 December 15 - Links for today &laquo; My (almost) Daily Links

# re: Silverlight Tip: Splash screen issues.

Monday, December 15, 2008 12:17 PM by APIJunkie

Hi Alexey,

If you want to work in managed code without limitations on what you can or can't use in your splash screen code. Checkout the silverlight loader project at:

www.codeplex.com/SilverlightLoader

Good luck!

 JB

# re: Silverlight Tip: Splash screen issues.

Tuesday, December 16, 2008 3:21 AM by brainbox

Thanks JB. I'll try it =)

# #.think.in infoDose #12 (15th Dec - 19th Dec)

Sunday, December 21, 2008 5:48 PM by #.think.in

#.think.in infoDose #12 (15th Dec - 19th Dec)

# re: Silverlight Tip: Splash screen issues.

Tuesday, December 23, 2008 2:49 PM by Alexandre

Sorry!... but I Tryed but don't work's for me....help me!!!

# re: Silverlight Tip: Splash screen issues.

Wednesday, December 24, 2008 10:55 AM by brainbox

May be u will provide a bit more info so I can guess what is wrong.

# re: Silverlight Tip: Splash screen issues.

Friday, January 09, 2009 12:37 AM by Bryant Likes

Great tip! Thanks!

# re: Silverlight Tip: Splash screen issues.

Thursday, July 16, 2009 10:59 AM by MurDoGG

Thx for this blog, great. I tried to use a custom splash screen for my vista gadget (hostet a silverlight app) because i want to update the gadget themselve. But i get always an error 2107, the the splash screen site must be in the same domain, it is, i think, any experience?

# re: Silverlight Tip: Splash screen issues.

Thursday, May 20, 2010 1:09 AM by Ritik Khatwani

Thanx for the post. Been tryin to figure out for a while how to get the javascript to report progress correctly in SL 2.

# re: Silverlight Tip: Splash screen issues.

Saturday, August 20, 2011 3:18 AM by felickz

THANKS!!! I went through the same exact progression you did... Try sample provided by MSDN, mess with it, try to center it, fail miserably in different ways.  Good thing i stumbled upon your blog soon after that!  

Leave a Comment

(required) 
(required) 
(optional)
(required)