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" >
<title>D2SIG - Developers & Designers Special Interest Group</title>
<form id="form1" runat="server" style="height: 100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<cc1:Silverlight ID="Silverlight1" runat="server"
</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:
Text="0"/><Run FontFamily="Trebuchet MS" Text="%"/>
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 (firstname.lastname@example.org)
Post a Comment:
Comment Title (required):
Your Name (optional):
Your Email (optional):
Your Web Site (optional):
Your Comment (required):