My First Silverlight Applicaion

Document Sample
My First Silverlight Applicaion Powered By Docstoc
					                        Creating a Basic Silverlight application

Hello everyone.

Its always a tough time to start with a new things whether it is a place, technology or language. This is
faced by each of us when we start new things. So to help the other people who are having a new start
with Silverlight, I have came out with this Silverlight material.

For starting development in Silverlight application, we need to know how to create a basic Silverlight
application. So for making a basic Silverlight application , kindly install all prerequisites and then
follow the below steps.

Steps for creating a basic Silverlight Application

   1. Open Visual Studio
   2. Go to File Menu , Select New Project
3. Select Silverlight option under your preferable language
   The selected language will be your code behind language.

4. Select Silverlight Application
   For creating a basic silverlight application, select “silverlight application” from the list of types
   of silverlight applications. You can select other as per the need of the application to be made.

5. Give your preferable name to the application and press “OK”

(All the above steps are shown in the below image with highlighted area.)
6. Select/Deselect the check box as required and press “OK”
   There are 2 check boxes for selection.
   A) Host the Silverlight application in a new Web site.
          Silverlight project cannot be hosted directly. So for hosting a silverlight project we
          require a Web Project. If you deselect or uncheck this checkbox, no web project will be
          added in this application. Only one silverlight project will be present in this application.
          One can change the name of the Web Project also. By default it gives
          “[ProjectName].Web” .

   B) Enable WCF RIA Services.
         If you want to use WCF RIA Services in your application, you need to select or check
         this checkbox.
7. IDE opens for starting Development.
   After you press “OK” in the previous screen, Visual Studio will open the IDE to start the
   development of the project.

   As you can see, there are 2 projects in this solution
   A) MyFirstSilverlightApplication
         This is a Silverlight Application in which you will be doing coding for development of
         the siverlight application. VS by default will add 2 pages (App.xaml and
         MainPage.xaml) to this project. App.xaml is entry page to this project.
       B) MyFirstSilverlightApplication.Web
            This is the web project for host the silverlight project. This project is created as we have
            checked the first check box in the popup “New Silverlight Application”. By default there
            will be a page “[ProjectName]TestPage.aspx” ( here
            “MyFirstSilverlightApplicationTestPage.aspx” ). This page will be displayed on the
            client's browser and silverlight projects will inside this page.

For better understanding I have added a “Textblock” specifying its text, font size and alignments in
MainPage.xaml which is the part of the Silverlight Project and not Web Project.

Now as we have created silverlight application let us run and try it out. When this application runs it
will give following output.

As you can see in the above image, the URL has the [ProjectName]TestPage.aspx and the content is of
MainPage.xaml. This shows that web project of our application is used to host our silverlight project.

Hope you have gained enough knowledge for creating a silverlight application.

Shared By: