Have questions about computing? Enlighten them on the Forum in this.
Invitations to the Live Mesh (Tech Preview) Tutorial - Outlook - Message of absence or vacation
May 13

silverlight2Beta Lately has been much talked about Silverlight, the commitment of Microsoft to compete with Macromedia's Flash. The first version of Silverlight was based heavily on the use of javascript and deploy very complex applications that were relatively complicated. Version 2 of Silverlight this whole paradigm has changed because the capacity was utilized. NET to develop Silverlight 2 applications. Now we can use C # for Silverlight development, and have a set of controls that help us much in development. In this tutorial I will explain how to create a simple application in Silverlight 2, to accommodate to this new platform.


What is Silverlight 2.0

The Silverlight 2.0 is a platform that allows us to develop rich applications for the Internet (RIAS - Rich Internet Applications). As the flash, you must also install a plugin in the browser to run Silverlight applications. This small plugin contains a reduced version of the platform. NET.

The capabilities of Silverlight 2.0 is huge and will play videos from high quality to the construction of complex applications, such as an application of analysis of the stock market. Silverlight applications using a language called XAML. It is with this language that we will define the interface of our Silverlight application. The logic of the application (code-behind) can be built using C # or VB.

Tutorial - Hello Silverlight 2.0

Now we have an idea of what is Silverlight 2.0, we will continue with the tutorial, where we create an application like "Hello World!".

Before we start with the tutorial itself, we need to have our development environment, ready to develop Silverlight 2.0 applications. For this there are some prerequisites:

To develop Silverlight 2.0 applications need a computer with Visual Studio 2008 and the Silverlight Tools installed. You can check this article to know how to install the Silverlight Tools:

http://www.istomesmo.com/2008/03/19/tutorial-instalar-as-silverlight-tools-beta-1-for-visual-studio-2008/

Microsoft Expression Blend and Deep Zoom Composer are optional components, are not necessary for the scope of this tutorial, but may investigate them if they want to build more complex applications.

Assuming that all components are already installed we start the tutorial, open the Visual Studio 2008 and creating a new Silverlight project type.

image

When you create a new project of type Silverlight 2.0, we asked if we want to create a web project to host / test the project Silverligth. For this tutorial we will say yes, and we want a web project of type "Web Application".

image

As we can see the next picture, our solution is a web application, where our project will be hosted Silverlight, Silverlight and the project itself. The Silverlight project is forming two XAML page, the App.xaml and Page.xaml.

image

For this tutorial we will just focus on us Page.xaml, which is the default which is open on the desktop when you create the solution.

image

At the bottom of Visual Studio, we have the XAML code of our Silverlight, which initially consists of a UserControl and a grid-type layout. Within the Grid we will create a button by adding the following code:

image

The attribute x: Name indicates the name of the button, the Width indicates the width, height Height and Content is the text that appears on the button.

image

Today we have our button created. If they want may be the solution, and we will see the button. We already have the button, we now add the click event to change your text where you clicked. To this we add an attribute to the button:

image

When we add the attribute click the Visual Studio 2008 gives us the option to immediately associate an Event Handler for the Click event, if we simply click on the Enter key. When you click Enter, Visual Studio creates the Event Handler in the Codebehind Page.xaml.

image

We then move to the Codebehind of the page, right-clicking the mouse on the area of design and choosing the option "View Code". In the Codebehind, we have the function btnHello_Click.

image

On the basis of the click of the button, we will create the logic to change the text of the same, each time it is clicked. adding the following code:

image

If we run the application when you click the button, the text will alternate between "Click here" and "Hello Silverlight 2."

image

We built our first Silverlight application, quickly and easily, including the use of events, with all the convenience of the platform. NET C #. :)

NOTE: For the web application is only downloaded a xap file that can find the application folder ClientBin Web

If you have any questions or concerns leave comment below.

rss_icon_glass_reflection64

If you liked this article subscribe to the RSS feed istomesmo to stay updated on the latest articles.

»Subscribe here fedde RSS '

Learn more about RSS fedde here


Articles that may interest you:

published by NC Etiquetas: appostilla, c #, flash, microsoft, RIA, silverlight 2, tutorial


6 Responses to "Tutorial - Introduction to Silverlight 2 (Hello World)"

  1. 1st Arthur Says:

    I like the Silverlight. Flash is yet to be long, but programming in C # instead of ActionScript is another level ...

    To see the power of the SL just see this: http://memorabilia.hardrock.com/

  2. 2nd Pasokon Says:

    I like Flash but Silverlight does not want to ... .. congratulations for the tutorial ...

  3. 3rd ndocosta Says:

    @ Pasokon
    The Silverlight is still at an early stage. Has great potential, but we see it not appeared too late. The flash is very implemented.

  4. 4th ndocosta Says:

    Artur @
    I fully agree. The example gives really great to see the potential of silverlight. And the convenience of programming with C # can be decisive in the evolution of Silverlight to the Flash. Let's see. Only time can tell us who is the winner. If he is going to be one. :)

  5. 5th Ennos Says:

    man earned the intro, it is nice to see that this new technology will burst.

  6. 6th Thailes Eduardo Says:

    Great tutorial, great investment with the Microsoft Silverlight agree more with the "ndoCosta" the flash is very implemented.

Leave a Reply