Silverlight 2.0 Beta 1 shipped yesterday, so I thought now would be a good time to deploy a new version of SilverLife. SilverLife is a Silverlight implementation of John Conway’s game of Life. Version 1.0, which I published in August of last year, targeted the Silverlight 1.1 alpha. Version 2.0 targets the new Silverlight 2.0 beta and can be viewed at You can download the source code from

SilverLife 2.0

SilverLife 2.0 looks almost exactly like version 1.0, save for the buttons at the bottom of the grid. Silverlight 1.1 had no controls built in, so I had to manufacture something that looked like buttons. Silverlight 2.0 Beta 1 contains more than 20 built-in control types, so I used Button controls. I also took advantage of the new style support in Silverlight 2.0 to stylize the buttons. First I defined a style named “LifeButton” in XAML:

<Style x:Key=”LifeButton” TargetType=”Button”>

  <Setter Property=”Width” Value=”132″ />

  <Setter Property=”Height” Value=”44″ />

  <Setter Property=”FontSize” Value=”16″ />



Then I applied the style to the four Button controls:


<Button x:Name=”StartButton” Style=”{StaticResource LifeButton}”/>

<Button x:Name=”StopButton” Style=”{StaticResource LifeButton}”/>

<Button x:Name=”StepButton” Style=”{StaticResource LifeButton}”/>

<Button x:Name=”ClearButton” Style=”{StaticResource LifeButton}”/>


This is an extremely simple example, but styles can be much more complex and can even use templates to completely redefine a control’s visual tree. Styles and templates are going to be incredibly important to Silverlight 2.0 apps, so I’ll be writing more about them later.

Porting SilverLife from Silverlight 1.1 to 2.0 required just a handful of changes. First I used Visual Studio 2008 to create a new Silverlight project. Then I imported most of the code and XAML from the first version of SilverLife and began patching things up. Here are some of the changes that were required:

  • The XamlReader class moved to the System.Windows.Markup namespace
  • XamlReader.Load now requires an xmlns=”” attribute
  • HtmlPage.Document.GetElementByID changed to HtmlPage.Document.GetElementById
  • The IsolatedStorageFileStream constructor now throws an IsolatedStorageException rather than an IOException if you attempt to open a file that doesn’t exist

One of the most pleasant surprises in Silverlight 2.0 Beta 1 is the simplified deployment strategy. XAML files and other resources (for example, images) are now compiled into the application’s assembly. Moreover, the assembly and any assemblies it depends upon are packaged in a XAP file, which is a glorified zip file containing a manifest. The upshot is that deploying the application to Wintellect’s Web server required two simple steps:

  • Copy Default.html (the page that hosts the application) into the Silverlife directory
  • Create a ClientBin folder in that directory and copy Silverlife.xap into it

That’s it! Other than adding a new MIME type (“application/x-silverlight-app”) to IIS and mapping it to XAP files (a one-time procedure), deployment involved nothing more copying a couple of files. How cool is that?

Another pleasant surprise was the fact that Silverlight 2.0 displays a default progress UI as the XAP file is downloaded. Now users won’t have to stare at a blank canvas as they wait for assemblies to be downloaded. Nor will you, the developer, have to code up a progress UI.

I’ll have much, much more to say in future posts. A new day is dawning, and it has Silverlight 2.0 written all over it!

  • wds_admin

    That’s cool. It’s even better if you write a book about Silverlight 2.0!

  • jprosise

    I think my book-writing days are over, John. But I appreciate the thought. 🙂

    I do have a novel in mind that I may try to write someday. I wonder if a geek author can become a fiction author?

  • wds_admin

    Is it supposed to do something? I am just staring at it waiting for something to happen after hitting “Start”…

  • jprosise

    You need to draw some cells into the grid first.

  • wds_admin

    Doh, boy is my face red 🙁

  • wds_admin

    I’ve installed Silverlight 2.0 Beta 1, but all I get when I visit is regeneration speed combo box, I don’t see main game area at all.

    BTW, I made the game for Silevrlight 2.0 too: Klotski, well-known from good old early Windows 3.1 days. You can si it at

  • wds_admin

    Nikola, I have the same problem. Some Silverlight 2 Beta 1 apps on the Web like Jeff’s just don’t display anything at all. Is this a bug in the runtime?

  • wds_admin

    I investigated a little, and I think I know why SilverLife works to some, and doesn’t to others. There is a bug in Silverlite beta 1 that is manifested only when in Regional options in Windows settings decimal symbol is comma (,) and not a dot (.)!

    However, program will work if in constructor in file Page.xaml.cs expression

    Rectangle rect = (Rectangle)XamlReader.Load(String.Format(_rect, x + 1, y + 1, _width – _spacing, _height – _spacing, _opacity));

    is replaced with

    Rectangle rect = (Rectangle)XamlReader.Load(String.Format(_rect, x + 1, y + 1, _width – _spacing, _height – _spacing, _opacity.ToString().Replace(‘,’, ‘.’)));

    This bug is left over from alpha version of Silverlight 1.1 and as far as I can see it is still not rectified.
    I hope that this will be settled in final version as in many countries decimal symbol is comma.

  • wds_admin

    Update: others have similar problem, check this out:

  • wds_admin

    Thanks for the heads-up! This seems to be the cause.

  • Does MS really need this bad pub?

  • Does MS really need this bad pub?

  • wds_admin

    Jeff – it’s a shame your book writing days are “over” – there are so few authors writing technical books worthy of the $60 price tags these days (Charles Petzold, Dino Espesito(?), Troelsen are very, very rare these days) – if you would tackle Silverlight you’d make another fortune 🙂