Silverlight Tip of the Day#2: Creating a Silverlight Application Project with Visual Studio 2008
[Blog Mirrored from https://silverlight.net/blogs/msnow/default.aspx]
To start, let's create a new Silverlight Application in Visual Studio 2008!
To do this, from the menu select File | New | Project as seen in Figure 1.1. If you wish to program in C# select Visual C# . If you wish to program in VB select the Other Languages | Visual Basic. Once you do this, choose Silverlight under Project types, then Silverlight Applications under the Templates window. Finally, set the Name, Location and Solution Name and click OK to finish.
Figure 2.1. New Project Dialog
In order to run a Silverlight application it must be hosted in a web page. The next dialog, as seen in Figure 2.2, gives you two options:
- Add a new Web to the solution for hosting the control. The first option allows you to have a web site auto-generated that is pre-configured to work with the Silverlight application. For these tutorials, this is the option we will be going with.
- Generate an HTML test page to host Silverlight within this project. The second option creates only a Silverlight Application. An HTML test page is dynamically created when you run the project for the purpose of testing the application.
Figure 2.2. Add Silverlight Application Dialog.
You now have a Silverlight Application! Let's review the different windows to get a full understanding of what you see.
Window #1: Solution Explorer.
In the upper right corner of Visual Studio is the solution explorer. The solution explorer, as seen in Figure 2.3, lists all the files involved with the newly created Web site and Silverlight application project.
The first project, in our case SilverlightApplication36.Web, contains the web site that is linked to your Silverlight Application project.
A brief description for each of these files:
- Default.aspx - This is an empty ASPX page. You can delete it if you do not need it.
- SilverlightApplication6TestPage.aspx - The ASPX version of a web page that hosts your Silverlight application.
- SilverlightApplication6TestPage.html - The HTML version of a web page that hosts your Silverlight application
- web.config - Settings and configurations for your web application.
Right click on either test page file you want to use and choose "Set As Start Page". This allows you to choose which file you want launched on start up.
Other files:
- App.xaml - The class inherits from the Application class and is a required component that is part of the entry point for Silverlight applications. This file is mostly used to store application resources (such as styles) that can be used throughout your application. In its code-behind file there are three events pre-configured for your use:
- Application_Startup - Put any initialization you need to perform before your application starts up.
- Application_Exit - Allows you to perform any action when the application is closed.
- Application_UnhandledException - This event allow you to intercept any unhandled exception in your application.
- Page.xaml - This is where you declare the UI and other objects for your application.
Window #2. Designer Preview.
This window, as shown in Figure 2.4, gives you a non-interactive preview of the control you have opened.
Figure 2.4. Designer Preview Window.
Window #3. XAML Code Editor.
This window, as shown in Figure 2.5, is where you can make your source code edits to the XAML file you have opened.
Window #4. Properties Window.
This window shows the properties of the selected file as shown in Figure 2 .6.
Figure 2.6. Properties Window.
Thank you,
--Mike Snow
Comments
- Anonymous
November 17, 2008
PingBack from http://blog.a-foton.ru/index.php/2008/11/18/silverlight-tip-of-the-day2-creating-a-silverlight-application-project-with-visual-studio-2008/