Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Get Started with Silverlight Using Visual Studio 2008 and Expression Blend 2 : Page 3

The Microsoft Silverlight browser plug-in enables developers to host Rich Internet Applications (RIAs), which feature animation, vector graphics, and video playback. Find out how to get started with Silverlight, and get a feel for how this new type of development works.


advertisement
Getting Started
With all the necessary tools installed, you can now create your first Silverlight application. Launch Visual Studio 2008 and create a new project. In the Project types, select Silverlight and then select the Silverlight Project template (see Figure 1). Name the project OurFirstSilverlightProject.


Figure 1. First Step: Creating a new Silverlight project.
 
Figure 2. The Foundation: All the basic files contained within the Silverlight project.

In the Solution Explorer, click the Show All Files button to reveal all the files that Visual Studio has added for the project. Figure 2 shows the files contained within it.



The following sections explain the basic files contained within a Silverlight project.

TestPage.html
This is a test page that you will use to test your Silverlight application. It contains the Silverlight control and references two JavaScript files—Silverlight.js and TestPage.html.js (their uses are explained in the next section). Listing 1 shows the content of TestPage.html.

HTML pages that host Silverlight controls can also contain other normal HTML elements that make up a web page. When you double-click on the TestPage.html file in Solution Explorer, Visual Studio 2008 will display the page in Split view, a new feature available in Visual Studio 2008. Using the Split view, you can view the HTML code and at the same time preview how it looks in a browser (see Figure 3).

Figure 3. Test Case: Displaying an HTML page in Split view.

TestPage.html.js
This file contains one JavaScript function that loads the Silverlight control onto the page. It also references the XAML file that contains the UI of your Silverlight application (Listing 2).

Each HTML page should have a corresponding JavaScript (.js) file that loads the Silverlight control contained in a relevant XAML File.

Page.xaml
This file contains the UI for your Silverlight application. Listing 3 shows the default content created by Visual Studio 2008.

Take note here of the x:Class attribute. In Listing 3, it specifies that the code-behind Class name is OurFirstSilverlightProject.Page (OurFirstSilverlightProject is the default root namespace of our project while Page is the class name), and its corresponding assembly is located in ClientBin/OurFirstSilverlightProject.dll.

Visual Studio 2008 provides IntelliSense support for XAML content, which is quite a handy feature if you're considering writing XAML manually.

Page.xaml.vb
This file contains the managed source code of our Silverlight application. The default class name used by Visual Studio 2008 is Page (Listing 4).

The Page.xaml.vb file is where you write your managed code. When a Silverlight application is ready for deployment, only the compiled assembly needs to be deployed. There is no need to deploy the source code.

Silverlight.js
This is the file provided by Microsoft that creates all the necessary plumbing needed to ensure that the target Web browser is able to run your Silverlight applications. By including this file in your application, the target Web browser will be asked to download the necessary runtime if the Silverlight runtime is not installed (every Silverlight application must include this file). Under the License Agreement, you are not allowed to modify this file. For Web servers that serve multiple Silverlight applications, you can simply put a single copy of this file in one location and set all the pages containing Silverlight content to point to this page.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap