|
||||||||||||||||||||||||||||||||||||
The best way to get started is to go to the Silverlight Getting Started page. From there you will eventually be directed to the download page for Silverlight Tools for Visual Studio 2008 SP1 which lists the following items as its contents:
Let's look at each of these in more detail but first an issue of terminology. While the Silverlight Tools download page refers to "Web reference support", what is really meant here is "Service Reference Support". While the reason for this will be explained in more detail later, to avoid confusion on the part of the reader, I will consistently refer to this as Service Reference support and not Web reference support. Also, what is meant by WCF templates is the Silverlight-enabled WCF Template. Again, for the sake of clarity, I will use the expanded description throughout this article. Note: The RTW version of Silverlight Tools was released on October 28, about two weeks after the official release of Silverlight 2 RTW. If you installed a version of Silverlight Tools between October 14 and October 28, it is recommended that you download the new version, uninstall the old version and then install the new version. Visual Basic and C# Project Templates
The Silverlight Application template is roughly comparable to other templates designed to produce executable applications, just like the Windows® Forms Application template or the WPF Application template. The Silverlight Class Library template is roughly comparable to a Windows Class Library template or any other project designed to create a .dll file.
Instead of the Form1.cs and Program.cs files that are found in the Windows Forms Application template, the Silverlight Application template provides Page.xaml and App.xaml files. Moreover, instead of the root element in Page.xaml being a Window as in the Window1.xaml file contained in a WPF Application template, the Silverlight root element is a User Control.
Every Silverlight application requires three Silverlight-specific assembly references: mscorlib, system, and System.Windows. Furthermore, in anticipation of typical Silverlight application functionality, the template also includes references to System.Core, System.Net, System.Windows.Browser and System.Xml. However, the template omits the System.Data, System.Data.DataSetExtensions, System.Deployment, System.Drawing, System.Windows.Forms and System.Xml.Linq assemblies which are provided by the Windows Forms Application template. An important effect of this combination of assemblies is to prevent the (easy) reference to classes which are inconsistent with Silverlight and which could not be processed by the Silverlight browser plugin. In fact, as the following screenshot shows, if you want to add a reference to additional assemblies, the list of available Microsoft .NET® assemblies is limited to only Silverlight-compatible choices.
Silverlight applications require an application manifest (AppManifest.xml) in order to generate the application package and accordingly, the Silverlight Application template provides this file in the Properties folder in a C# application and in the My Project folder in Visual Basic.NET. A second file in that folder, the AssemblyInfo.cs file, is roughly comparable to the equivalent file contained in a Windows Forms or a WPF application. Project templates are also responsible for setting various project properties. In the case of a Silverlight Application template, the Startup object is set to the App object contained in the App.xaml file. (Technically, since a Silverlight application must always be contained in a web page of some sort, this might better have been labeled the "Entry Point".) The Startup object property is unset by default in both Windows Forms and WPF applications.
Although Visual Studio 2008 Professional Edition allows both Windows Forms and WPF applications to target different .NET Frameworks (versions 2.0, 3.0 or 3.5) and to select an output type (Windows Application, Console Application or Class Library), these choices are not available under the Silverlight Application template. Interestingly, all of the Silverlight assemblies carry a 2.0.5.0 version number indicating that their version number is tied to Silverlight 2 and not to any specific version of the .NET Framework (See Figure 4, above). Silverlight applications must always be packaged in a .xap file. This is specified by the template although the developer is permitted to change the name as desired. Silverlight content must be hosted on a web page of some type. As Visual Studio builds a Silverlight application, it gives you a choice of hosting your Silverlight content in either an ASP.NET web application or in a dynamically generated HTML page. The dynamically generated HTML page option is a convenience where you want to develop your Silverlight content independent of any additional content on the web page, perhaps because another developer has that responsibility. No setup or other effort of any sort is required when this option is selected. However, in most instances the web application will be a preferable option because it gives you a choice of either an .aspx page or an .html page which you can then customize as a permanent container for your Silverlight content. This option is especially desirable if you plan to have additional non-Silverlight web pages or a WCF Service (discussed later) in your web site. Using a web application project also facilitates deployment because all that needs to be uploaded to your web server is the ClientBin folder, the web page hosting your Silverlight content and any other web pages (and associated assets) that you have added to the project.
The Debug tab for a Silverlight application offers a choice between a dynamically generated test page and a user specified html type page. This option only matters in the case where the Silverlight project is the startup project which is generally only true if the developer has declined the ASP.NET Web project choice (see Figure 6 above).
Where the developer has chosen an ASP.NET Web project, the startup object is set by choosing the "Set as Start Page" option from the desired web page's context menu.
On the Build Tab, the Silverlight Application template disables a couple of settings which do not apply to Silverlight applications.
A Silverlight application's project properties do not include tabs for Resources, Services, Settings, Security or Publish, as is the case for a Windows Forms application. The Build Events, Reference Paths and Signing tabs are identical for both Silverlight and Windows Forms applications with the exception that ClickOnce signing is inapplicable to Silverlight applications for the obvious reason that Silverlight applications do not use ClickOnce. The differences between a Silverlight Class Library project and a Windows Class Library project are not quite as extensive as in the case of a Silverlight Application project, but there are meaningful differences, nonetheless. Both a Silverlight Class Library project and a Windows Class Library have a code file named Class1.cs and an AssemblyInfo.cs file. The primary distinction visible in the Solution Explorer pane is the difference in referenced assemblies as illustrated in Figures 10 and 11. The explanation of these differences for a Silverlight Class Library project is the same as for a Silverlight Application project.
All of the project properties of a Silverlight Class Library are the same as those of a Silverlight Application except that the Class Library project cannot set its startup object or specify any build options. Technically the Silverlight Tools package contains a third template--an items template for a Silverlight User Control which is included in a Silverlight Application template. The Silverlight User Control items template consists of a Page.xaml file and the associated code behind file, Page.xaml.cs.
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
|