Welcome to the Milos Blog!

Sunday, July 19, 2009
Silverlight ASP.NET Server Control Update

Here's a bit more on our ASP.NET Silverlight Control I talked about recently: We now updated this control to not just be compatible with the old control shipped by Microsoft, but to do things you might find useful. Here is a list of changes:

  • Default minimum version is now set to 3.0
  • Removed the ScaleMode property, since that just isn't supported by Silverlight anymore
  • Added the ability to very easily set that a control uses 100% of the available browser space
  • Added the ability to fire a storyboard in a splash screen XAML file
  • Added the ability to update a string in the splash screen that represents current download progress

Here is an example aspx file containing a Silverlight control (this one is from www.D2SIG.org):

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="D2SIGWeb._Default" %>
<%@ Register assembly="SimpleWebControls" namespace="EPS.Web.SimpleControls" tagprefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
html xmlns="http://www.w3.org/1999/xhtml" >
  <
head runat="server">
   
<title>D2SIG - Developers &amp; Designers Special Interest Group</title>
 
</
head>
 
<
body>
   
<form id="form1" runat="server" style="height: 100%;">
     
<asp:ScriptManager ID="ScriptManager1" runat="server">
     
</asp:ScriptManager>
   
     
<cc1:Silverlight ID="Silverlight1" runat="server"
          
Source="~/ClientBin/D2SIGSL.xap"
          
DisplayMode="FullBrowser"
           SplashScreenSource="~/D2SIGLoading.xaml"
           
SplashScreenProgressUpdateObjectId="ProgressLabel"
          
SplashScreenStoryboard="Loading">
     
</cc1:Silverlight>
   
</form>
 
</
body>

</html>

Note that there are no div tags required anymore (you can still add them if you want to, but it is handled by the control automatically). Also, no CSS styles have to be defined for the 100% height and width anywhere. Instead, the DisplayMode of the control is set to FullBrowser, which handles the 100% height and width right in all browsers.

Also note that this example fires a storyboard called "Loading", which is inside the resources of the D2SIGLoading.xaml file.

Furthermore, that XAML file has a text run called "ProgressLabel" which is automatically updated with the current download percentage rounded to full numbers. The XAML file has a text run inside a textblock that is defined like this:

<TextBlock Height="14"
          
HorizontalAlignment="Center"
          
Width="45"
          
Canvas.Top="54"
          
TextAlignment="Center"
          
Foreground="#FF646464"
>
   
<
Run x:Name="ProgressLabel"
        
FontFamily="Trebuchet MS"
        
Text="0"/><Run FontFamily="Trebuchet MS" Text="%"
/>
</
TextBlock>

Note that whatever object is specified as the progress update object must have a Text property of type string. Note that you can create custom objects with that property, which will automatically be updated as progress changes. You could then do whatever you'd like with that value, including parsing it as a number and use that for further calculations.

 

Posted @ 4:16 PM by Egger, Markus (markus@code-magazine.com)


Post a Comment:

Comment Title (required):

Your Name (optional):

Your Email (optional):

Your Web Site (optional):

Your Comment (required):


Archive:
November, 2010 (1)
July, 2009 (2)
February, 2009 (2)
January, 2009 (1)
December, 2008 (1)
October, 2008 (3)
June, 2008 (1)
April, 2008 (3)
February, 2008 (1)
January, 2008 (1)
December, 2007 (1)
October, 2007 (2)
September, 2007 (2)
July, 2007 (1)
June, 2007 (2)
May, 2007 (4)
April, 2007 (6)
March, 2007 (8)
February, 2007 (3)
January, 2007 (2)
December, 2006 (2)
November, 2006 (2)


Blog Stats:
Posts: 51
RSS Syndication

Contact:

EPS Software Corp.
6605 Cypresswood Dr., Suite 300
Spring, TX 77379
United States

Phone: 832-717-4445
Email: info@MilosSolutionPlatform.com

Other EPS Properties

EPS Software Homepage
EPS Custom Software
CoDe Magazine
CoDe Focus Magazine
VFPConversion.com
WPFExperts.com
MarkusEgger.com

(c) by EPS Software Corp. 2001 - 2013