This tutorial will show you how to create a simple Silverlight Application.
Many thanks to my friend Hassan-Mia Salie for his contributions.
Prerequisites
• Visual Studio 2008 SP1
• Microsoft® Silverlight™ 3 Tools for Visual Studio 2008 SP1
Available for download here
The package will install the following components:
Silverlight 3 developer runtime
Silverlight 3 software development kit
Silverlight 3 Tools for Visual Studio 2008 SP1
Create the Silverlight Application
• Launch VS2008
• Create new project --> Visual C# --> Silverlight --> Silverlight Application
Select the following:
The following components are automatically added to the solution.
Open MainPage.xaml in design view:
<UserControl x:Class="MySilverLightApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot">
</Grid>
</UserControl>
Add code in the Grid section.
<Button Name="cmdHello" Content="Click to view time." Width="200" Height="40" Click="Button_Click"></Button> Open MainPage.xaml.cs
Add the following:
cmdHello.Content = System.DateTime.Now.TimeOfDay.ToString();
to:
private void Button_Click(object sender, RoutedEventArgs e)
{
cmdHello.Content = System.DateTime.Now.TimeOfDay.ToString();
}
Build the solution.
Right click on MySilverLightAppTestPage.aspx and select “View in browser”
Open the Bin\Debug folder and see the output:
- AppManifest.xaml
- MySilverLightApp.dll
- MySilverLightApp.pdb
- MySilverLightApp.xap
- TestPage.html
0 comments:
Post a Comment