Create the Silverlight project
- Open Visual Studio 2008
- Click File->New Project
- Under Visual C# click Silverlight
- Select Silverlight Application, name it what you want, and click ok
- When it asks you if you would like to create a web project, click add a new and click ok
Now you should have two projects. Under the library, click and open up your Page.xaml file. You are going to add xaml to the Grid control so that it looks like this:
Then in the Page.xaml.cs file, you need to add the code for the button’s Click event:
Now you can build the application, but it is not quite publish ready.
Publishing the application
First thing we need to do is create a publish version of the application.
- Right click on the web application and click "Publish Website”
- Specify your publish location (I used the desktop), and click ok
Now the issue with publishing Silverlight 2 is that webservers don’t recognize the xap file as a proper mime type. The good thing is xap files are essentially just zip files. With this in mind, we can use some wizard trickery to make it all work happily.
- Go to the folder where you published your web application
- There should be a .xap file in your ClientBin directory. Change the file extension file to .zip instead of .xap
- Go to any pages that reference this file (Visual Studio will have created a [ProjectName]TestPage.aspx and .html file.
- Open the SilverlightDeployTestPage.html and find the object section.
- Rename the .xap reference to .zip as done in the ClientBin file
You should be good to go. You can now ftp the site wherever your heart desires and it will work. For now, you have to do this for all of the references to your xap files. I’ll keep you posted (No pun intended).