Partager via


My first Silverlight 1.1 app

Here's my first Silverlight 1.1 (which has .NET support) app. It bounces various shapes around the canvas. (Stop laughing! )

I didn't know how to host a SL 1.1 control on this blog server, so I hosted it at my own server here. Here's a screenshot (click on it to go to the actual page and see it in action):

image

You obviously need to download Silverlight 1.1  for this to work, but the download is very easy, fast (< 30 seconds), and actually works. The silverlight install is orders of magnitude better than the desktop install; there's been a lot of of effort into getting it right.

FWIW, it's also my first Xaml app. Working on debugging APIs doesn't exactly give you lots of opportunities to play with the current UI technologies. The prior GUI stuff (like the GUI for Mdbg) I've done has been with WinForms and a very tiny bit with win32.

How does it work?

The page has links to the C# and Xaml code if you're interested in seeing how any of it was done.

The bouncing shapes are .jpg images, which I proudly drew myself in mspaint.

The Xaml handles the layout and minor animations that can be described in a declarative manner (such as the rotations and stretching).  The ambient animation and opacity are basically freebies with Xaml, and that's just scratching the surface of what's available.
The C# code handles the bouncing logic, which is a tad more complicated than a simple linear animation on a property.  It sets up a timer callback, and then the callback adjusts the image locations to do the animations. The timer callback needs to be on the UI thread so that I can adjust UI elements without cross-thread overhead. I used System.Windows.Browser.HtmlTimer for that. That's marked deprecated, but I haven't found an adequate replacement yet.

Looks like Silverlight1.1 doesn't yet have a button, so the pause/resume button is a hacked up ellipse with OnEnter/OnExit/OnClick handlers.

It all runs on the client, which is a major point of Silverlight. I built it with the Visual Studio Orcas beta + Silverlight Tools update. See the SL 1.1 Quickstart Tutorial for more details.

 

Concluding thoughts:

It's not exactly the most practical use of Silverlight 1.1, but a cute starter project. It doesn't do anything fancy with Xaml, and it doesn't take advantage of Silverlight's cooler features like streaming media and richer rendering. I suppose I could throw some paddles in there and make it a pong game or something.

Comments

  • Anonymous
    May 18, 2007
    Very nice.  However, I can not download the source C# file.

  • Anonymous
    May 18, 2007
    Is the .cs file missing on your server?

  • Anonymous
    May 18, 2007
    I guess a direct link to a .cs file doesn't work so well. I updated it with a link to a .zip that contains the entire solution.

  • Anonymous
    May 19, 2007
    >>Looks like Silverlight1.1 doesn't yet have a button Actually it does :) See http://nerddawg.blogspot.com/2007/05/silverlight-ui-controls.html

  • Anonymous
    May 23, 2007
    http://go.microsoft.com/fwlink/?LinkID=86008 seems to go to 1.0 not 1.1

  • Anonymous
    May 24, 2007
    Matthew - you're right. The 1.1 link should be: http://msdn.microsoft.com/vstudio/eula.aspx?id=e2c1a44f-0b5c-face-28c8-08a26f2e0b3c I'll update the entry above. Thanks.

  • Anonymous
    May 30, 2007
    I noticed something interesting with this app.. if you highlight some of the text underneath it and attempt to drag that selection over the bouncing shapes, it stops..  hover like this for say 5 seconds, and release.. it catches up with itself at higher speed! Thought you might want to debug why out of interest!