Tutorials » Silverlight tutorials »

Build and run your Silverlight hello World application


In this chapter, you will learn how to build and run your Silverlight application


It is time to build and run your first Silverlight application. Press Ctrl+F5 to build and run your application. If everything is setup correctly, then Internet Explorer will be launched automatically with your default page which hosts your Silverlight object.

Since you have not done much for your control, you will see a blank page opened in the browser.

Go back to your Visual Studio and open your web page which hosts the Silverlight object. In my sample project, the file is named "MySilverlightAppTestPage.aspx" and the content of the file looks like this:

 
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="System.Web.Silverlight"
Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %>
<!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" style="height:100%;">
<head runat="server">
<title>Test Page For MySilverlightApp</title>
</head>
<body style="height:100%;margin:0;">
<form id="form1" runat="server" style="height:100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div style="height:100%;">
<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/MySilverlightApp.xap"
MinimumVersion="2.0.30523" Width="100%" Height="100%" />
</div>
</form>
</body>
</html>


Most of the stuff above look familiar to ASP.NET developers. Some of the lines that need some attention are:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/MySilverlightApp.xap"
MinimumVersion="2.0.30523" Width="100%" Height="100%" />


The second line defines the Silverlight control to be hosted in the web page. The attribute "Source" defines the .xap file to be used by the web page. This .xap file contains the XAML and code from your .xaml files and will be executed by the Silverlight plugin.

In the current sample, you have just one xaml file called Page.xaml. When you compile the solution, this file is compiled into a special file (MySilverlightApp.xap) with the extension .xap.




Next Chapter: What is app.xaml ?
Previous Chapter: Files created by Visual Studio by default
More Chapters: Silverlight Tutorials
More Tutorials: Tutorial Index



Top Contributors
TodayLast 7 Daysmore...

Awards & Gifts

Online Members

More...
 
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India