Getting Started

NOTE: This post is obsolete. Please go to this link for more info:

http://silverlightrocks.com/community/blogs/silverlight_games_101/archive/2008/03/12/back-to-the-beginning-sorta.aspx 

Source code for this tutorial: http://silverlightrocks.com/Community/files/folders/slg101_tutorials/entry8.aspx

Ok so now if you have set up your environment by installing everything listed in the last post, we should be ready to create a Silverlight Project.

In Visual Studio "Orcas", create a new C# project of type "Silverlight Project". Call it "SpaceRocks". This project will be the basis for the first set of tutorials we'll go through.

Now run your project. If all goes well, one of two things will happen.

Outcome 1: You will get prompted with a "Get Silverlight Alpha" control. Go ahead and install Silverlight 1.1 Alpha by clicking on the control.

Outcome 2: You'll get a blank page.

Ok so by now you should be seeing a blank page. Why a blank page? Well the default background color for a new Silverlight project is White. If you look at your Page.xaml file, it will look like this:

 

<Canvas x:Name="parentCanvas"
        xmlns="http://schemas.microsoft.com/client/2007" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        Loaded="Page_Loaded" 
        x:Class="SpaceRocks.Page;assembly=ClientBin/SpaceRocks.dll"
        Width="640"
        Height="480"
        Background="White"
        >

</Canvas>

XAML files are used for forms layout, similar to HTML for a web page. Typically in Silverlight you will lay out your page and controls using XAML and then use code behind to handle the events, kick off animations, etc. Visual Studio "Orcas" does not currently have designer support for Silverlight controls and pages, but if you right click on the file in Solution Explorer, there is an "Open in Expression Blend..." option. Expression Blend is a tool which allows you to lay out XAML based controls, add animations, and more. 

Back to Visual Studio...change the Background attribute to "Black" and run it again. Now you should have a black box 640x480 inside the browser.

Published Friday, May 11, 2007 2:39 PM by Bill Reiss

Comments

# re: Getting Started

Hi Bill.

Thanks for your great blog - I am following your tutorials; exciting to program my first game with Silverlight…

I installed the development environment you specified (Windows Server 2003)

When I run the first tutorial I received blank page, when I open Page.xaml with the designer, I got “Intentionally left Blank” – and I found error for the “Canvas” – “The type ‘Canvas’ was not found….”

BTW – I found the same problem with sample provided by Microsoft.

What I am doing wrong?

Thanks Alon

Sunday, September 09, 2007 7:48 AM by bodeg

# re: Getting Started

Bill.

It seems that the problem was with my Internet security settings - once I changed it, it works...

alon.

Sunday, September 09, 2007 8:17 AM by bodeg

# re: Getting Started

Glad you got it worked out, I look forward to hearing about what you come up with.

Sunday, September 09, 2007 9:23 AM by Bill Reiss

# re: Getting Started

Great! I got everything installed and everything works good so far! Thanks, Bill and keep up the great work!

Wednesday, October 17, 2007 8:47 PM by gamerpsp360

# re: Getting Started

So... I don't know if I'm doing something wrong or not. I'm using a the standard version of VS 2008 and have created a new silverlight project.

My xaml page is a UserControl and not a Convas. Is that something new or have I done something wrong (perhaps don't have the correct software installed?)

Thanks for any tips.

Thursday, May 22, 2008 7:38 PM by chumad

# re: Getting Started

Yep these posts are old (for Silverlight 1.1) go here for the updated posts:

silverlightrocks.com/.../back-to-the-beginning-sorta.aspx

Thursday, May 22, 2008 7:45 PM by Bill Reiss