How to Set the Development Environment?
To go with the following I advice you to go first with
following link: http://www.silverlight.net/GetStarted
Following are the steps to set up the Environment,
1. Install Visual Studio 2008 with
Visual Web Developer Feature.
2. Install SilverLight Plug-in:
download Silverlight Plug-in from http://www.microsoft.com/silverlight
and Install Silverlight2, make sure you have uninstalled all previous versions
of Silverlight.
How to Install Silverlight SDK
Go to, http://www.silverlight.net/GetStarted
Installation of Silverlight SDK depends upon your
environment, like if you have Visual Studio 2008 installed or not on your
computer.
If you have VS2008 Installed
Install Silverlight for Visual Studio from the above
link which installs following(s):
Ø
Silverlight 2 plug-in
Ø
Silverlight SDK
Ø
Visual Basic and C# Templates
Ø
Code generators for XAML
Ø
Debugging for Silverlight application
Ø
Integration with expression Blend.
If you have not ‘VS2008’ Installed
To download an install go with the following(s):
Ø
Click on install
Ø
Review the requirements
Ø
Download and save the file in your local system.
Ø
Now double click the downloaded file
Steps to start your First Silverlight application
Following are the initial steps to give the overview to
just start first application:
Ø
Select File -> New -> Project from Main Menu of Visual
Studio
Ø
Select C# / Visual Basic from the project types
Ø
From Template list select Silverlight Template.
Ø
Enter project name and location then create a new project.
Ø
To host Silverlight within the project, select generate HTML test
page.
Ø
Finally click ok.
Ø
The page.xaml appears
Ø
From toolbox drag and drop any control on the page.
Ø
Modify the control and then save the page.xaml file.
Ø
To get into code-behind double click on the control
Ø
Write some test message: Like “Hello I am started!”
Ø
Now build and test the changes.
Code in Page.xaml:
<UserControl x:Class="myFirstSilverlightApp.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot"
Background="White">
<Button x:Name="myButton"
Canvas.Top="75"
Canvas.Left="150"
Content="Click Me"
Height="37"
Width="118" Click="myButton_Click"
ToolTipService.ToolTip ="Click to change above
text"/>
</Grid>
</UserControl>
Code in Page.xaml.cs:
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using
System.Windows.Controls;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Animation;
using
System.Windows.Shapes;
namespace
myFirstSilverlightApp
{
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
}
private void myButton_Click(object sender, RoutedEventArgs e)
{
myButton.Content = "Hello I am started!";
}
}
}
Following is the output of the application:
|