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 https://training.atmosera.com/silverlife. You can download the source code from training.atmosera.com/downloads/silverlife_2.0.zip.
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″ />
</Style>
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:
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:
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!
Microsoft Azure and Amazon Web Services (AWS) are two of the most popular cloud platforms.…
Cloud management is difficult to do manually, especially if you work with multiple cloud…
Azure’s scalable infrastructure is often cited as one of the primary reasons why it's the…
https://www.youtube.com/watch?v=wDzCN0d8SeA Watch our "Unlocking the Power of AI in your Software Development Life Cycle (SDLC)"…
FinOps is a strategic approach to managing cloud costs. It combines financial management best practices…
Using Kubernetes with Azure combines the power of Kubernetes container orchestration and the cloud capabilities…
View Comments
That's cool. It's even better if you write a book about Silverlight 2.0!
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?
Is it supposed to do something? I am just staring at it waiting for something to happen after hitting "Start"...
You need to draw some cells into the grid first.
Doh, boy is my face red :(
I've installed Silverlight 2.0 Beta 1, but all I get when I visit https://training.atmosera.com/silverlife 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 http://www.phy.hr/~nikola/klotski/
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?
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.
Update: others have similar problem, check this out: http://silverlight.net/forums/t/4142.aspx
Thanks for the heads-up! This seems to be the cause.