Creating a Silverlight project for the Web
We are beginning this tutorial by the creation of a project for a Web application, running in a navigator, and who requires the Silverlight plug-in, plus the SDK for us, the programmers.
1) Installing the SDK
The Silverlight SDK comprises a tutorial and a documentation. The first stage
will consist to download it and install it. See the instructions on the Silverlight
Once the runtinme installed on your computer, the browsers are able to display web pages with a rich interface.
2) Creating a directory
For example c:\demo, where your project will be placed.
3) Copying the script
You will find the script of initialization in the following directory:
Program Files/Microsoft Silverlight 1.0 SDK/Tools/Silverlight.js/Silverlight.js
Copy it in the directory that you have just created. This script checks that the system supports XAML.
4) Creating a Web page.
You can use the SampleHTML.html example page in the same directory as aghost.js, but any page created by Open Office for example can be appropriate.
5) Adding a script
The standard script must be inserted in the Web page with the following line, placed between the <head> and </head> tags:
You can also add a line for your own script:
6) Creating a ActiveX object
A XAML Program is inserted in the page as a ActiveX control. To insert the
control, a container is required, generally a <div> tag, and a code
of initialization. It is possible to add several controls, thus several couples
Practically one creates a ActiveX control by adding a line in the Web page, between the tags <body> and </body>:
<! -- Where the Silverlight plugin will go--> <div id="myControl"> </div>
7) Configuring the ActiveX object
Insert the code below after the preceding line.
Description of each statement:
- Create the ActiveX Silverlight control.
- It is the name of the source file containing the XAML code. You can of course change this name.
- Identifier of the element in which the control
will be inserted, it is the preceding div.
Generally, it is a <div>. If you give another name to this container, change it here too.
- The identifier of the control to be created.
- Width of control, followed by the height.
- Flag to displaying a message when a bad version is detected.
- Background color.
- Control displayed without a window, when false. If a window is opened, set to "true".
- Number of displays per second.
- Version number for the plugin used at development.
- Name of error event handler or null if none.
- Name of loading event hangler or null if none.
- Name of the function for error processing, null if there is no suchfunction, its name otherwise.
8) Creating the XAML source file
It is a simple text file, whose name is given as argument above, myxaml.xaml.
Unless you use a different name as parameter in the initialization.
You have the following files now:
Your XAML project for Silverlight is complete. it remains to add code and it will be in the next steps.