1. Download and install Silverlight: Microsoft Silverlight 3 tools (upgrade vs2008 to SP1 before installation)
2. Like most people, myProgramFinally, after I installed it, I got OK, and there was no error in running the vs2008 project. I sorted out my own installation sequence: vs2008 (later vs2010 was installed ), framework3.5-SP1, VS2008-SP1, silverlight3,silverlight_cmd.exe.
3. Create a project and create a Silverlight Navigation Application
Find the home. XAML file F5 in views for debugging and running.
Add the Silverlight control: button and textbox.
Double-click button writingCode
Home. XAML Page code:
Code
< Navigation: page X: Class = " Silverlightapplication3.home " 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 " Xmlns: navigation = " CLR-namespace: system. Windows. controls; Assembly = system. Windows. Controls. Navigation " MC: ignorable = " D " D: designwidth = " 640 " D: designheight = " 480 " Title = " Home Page " Style = " {Staticresource pagestyle} " Xmlns: datainput = " CLR-namespace: system. Windows. controls; Assembly = system. Windows. Controls. Data. Input " >
grid X: name = " layoutroot " >
scrollviewer X: Name = " pagescrollviewer " style = " {staticresource pagescrollviewerstyle} " >
<Stackpanel X: Name="Contentstackpanel">
< Textblock X: Name = " Headertext " Style = " {Staticresource headertextstyle} " Text = " Home Page " />
< Button content = " Click me " Height = " 42 " Name = " Button1 " Width = " 119 " Click = " Button#click " Fontsize = " 16 " Fontweight = " Bold " />
< Textblock X: Name = " Contenttext " Style = " {Staticresource contenttextstyle} " Text = " Homepage content " />
< Textbox height = " 23 " Name = " Textbox1 " Width = " 120 " />
</ Stackpanel >
</Scrollviewer>
</Grid>
</Navigation: Page>
Home. XAML. CS
Code
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. Navigation;
Using System. Windows. shapes;
namespace silverlightapplication3
{< br> Public partial class Home: page
{< br> Public Home ()
{< br> initializecomponent ();
}
//Run the command when you navigate to this page.
Protected Override VoidOnnavigatedto (navigationeventargs E)
{
}
Private Void Button#click ( Object Sender, routedeventargs E)
{
Headertext. Text = " My first Silverlight application! " ;
Textbox1.text = Datetime. Now. tostring ();
}
}
}