Monday, 30 March 2009

Silverlight: SL3 Navigation Screencasts

In this first video, I show how to get started with the new Silverlight 3 Navigation feature.


In this second video, I show you how to use the new Uri Mapper and deep linking feature.

Thursday, 26 March 2009

Silverlight: GPU reverts to CPU Screencast

In my previous screencast, i showed you the benefits of GPU acceleration in Silverlight 3 and how to make use of it, as well of an instance where enabling GPU acceleration will harm performance.

In this screencast, I will show you that in certain scenarios even though you have enabled GPU acceleration, Silverlight will revert to the CPU.  Specifically we cover RenderTransforms, Pixel Shader Effects and 3D Perspective (Plane Projections).  Video is below.


Wednesday, 25 March 2009

Silverlight: GPU Acceleration Screencast

I wanted to do a screencast on Silverlight GPU Acceleration

Hopefully this video should show how to use GPU acceleration and when to use it, and an instance of when you might not want to use it.

There are lots of other instances of when you would want to, and not want to use GPU acceleration (and I will probably cover them in future videos), as I like to keep the screencasts short.

Tuesday, 24 March 2009

Silverlight: SL3 WriteableBitmap Video

I've spent a little time now with the Silverlight 3 WriteableBitmap stuff (playing with my Spectrum Emulator).  So I thought I'd make a little video going through using it.

I show you how to use WriteableBitmap to generate some random noise, some gotchas and show how the emulator makes use of WriteableBitmap.

Silverlight 3 WriteableBitmap can be viewed from here or below

Monday, 23 March 2009

Silverlight: SLLauncher

This is just a quick post about debugging in Silverlight 3 “Out of Browser” mode.

Your offline Silverlight application does not run in Internet Explore but will run in the a standalone executable called “SLLauncher.exe” which ships with Silverlight.  SLLauncher is essentially a windows application which hosts a browser control (and on the Mac it hosts webkit).  In windows look at (C:\Program Files\Microsoft Silverlight\3.0.40307.0\sllauncher.exe).

This means that is you were to look for your “out of browser” silverlight application in Task Manager it will be listed as “SLLauncher.exe”.  The bad new is that (for the beta) it does not list in taskmanager any details of the application running, it will just show as “sllauncher.exe”, this means you can’t distinguish between multiple “out of browser” applications running on your machine.


This means if you wish to debug your SLOOB application, then you will need to attach to the sllauncher process.  Visual Studio will not automatically attach to your SLOOB application.

Saturday, 21 March 2009

Silverlight: Web Pixel Shader Compiler

So I've built a very quick silverlight application (I will tidy it up later), that will compile your pixel shader code for you.  This saves you from downloading the DirectX SDK.

The url to use the compiler is here:

A little screenshot is below:


In the first textbox, enter the name of your .ps file (do not include the .ps extension).

In the second textbox, enter the contents of your .fx file.

Click on the compile button, and it will give you a link to download your .ps file.

You can the include your .ps file into your silverlight 3 application.

For more details on creating custom pixel shaders see this blog entry from Andy Beaulieu 

I will probably do a quick video on using this tool soon, and will tidy it up to make it look a little more professional at a later date.

In the mean time, feel free to go to: and compile them for use in Silverlight at

Silverlight: WriteableBitmap Gotchas

So I updated my Silverlight Spectrum Emulator to work with Silverlight 3 and in this process I used the new WriteableBitmap class.

I just wanted to make you aware of a few gotchas that I experienced whilst working with this.

Set the Image Source everytime

Gotcha number 1, for some reason after updating a bitmap, you must reset the source of the image to your bitmap.  If you don't then you will get very jerky updates (it won't re-render every time).

Out of Memory Exceptions

Due to gotcha number 1, you may be tempted touse a local variable for the WriteableBitmap, and then set the source of the image.  DO NOT do this, as it will steal all your memory, and you will get an out of memory exception.

To get around this you should scope your WriteableBitmap to your page, and thus you will avoid the out of memory exception

Silverlight: Pixel Shader Libraries

So I absolutely love the support for pixel shaders in Silverlight 3.  You can apply some pretty cool effects (DropShadow and Blur are built in), or you can apply custom effects.

The method for producing custom shaders in SL3 is the same as WPF, which means that any custom shaders that are produced for WPF should work for Silverlight (this is a big assumption as I haven't tried it yet)

Creating custom pixel shaders is not the sort of task that everyday coders (including me), do.  However any shaders produced by other people, we are quite happy to use.

In codeplex there is a nice custom shader library for WPF (for which I see no reason wouldn't work for silverlight 3, caveat is I haven't tried it yet).

Effects include

Effects: BandedSwirl, Bloom, BrightExtract, ColorKeyAlpha, ColorTone, ContrastAdjust, DirectionalBlur, Embossed, Gloom, GrowablePoissonDiskEffect, InvertColor, LightStreak, Magnify, Monochrome, Pinch, Pixelate, Ripple, Sharpen, SmoothMagnify, Swirl, Tone, Toon, and ZoomBlur

I will try and grab some time, and try sticking one of the effects on SL3, and let you know the results

Friday, 20 March 2009

Silverlight: SL3 Dropshadows are slow

This is probably no great surprise to anyone but bitmap effects have quite a significant performance hit on your CPU.

The following code is an example of how to apply a drop shadow

<Button Content="Drop Shadow Under Me" Width="200">
<DropShadowEffect Color="Black" Direction="320"
ShadowDepth="25" BlurRadius="5" Opacity="0.5" />

So just be aware before you start apply dropshadows to every button / element on the page that it will slow your application down.

Just be considerate in your use (and always check your performance), especially since some effects (such as dropshadow) can easily be produced using more performant techniques.

Thursday, 19 March 2009

Silverlight: SL3 Spectrum Emulator

Ok, so I updated the spectrum emulator to run in Silverlight 3.

The performance is now amazing, due to GPU Acceleration, WriteableBitmap, and it also runs out of browser (right click and install).

I guess I will update it with more SL3 features at some point. Have fun writing spectrum basic, and playing manic miner etc.


Click your mouse within the emulator to begin

Symbol Shift is the Home Key, Remember Shift 0 is backspace, and Symbol Shift (home) P is a quote mark.

The emulator works with .SNA files, which you should be able to download from various sites and run via the Open File option, just search for .sna and whatever game.

Click here for an the layout of the spectrum keyboard

Play with it

Wednesday, 18 March 2009

Silverlight: OOB: Detach, user cancelling and exceptions

So there is a couple of things I want you to be aware of when detaching your Silverlight application

App.Current.Detach() returns a boolean

If the user selects cancel, then it will return false, otherwise it will return true.  You need to check for this, rather than assuming it worked.

Exceptions if you are already detached

You will receive a very nice InvalidOperationException with a message stating your application is already detached (if you attempt to detach your application, and you are already detached).

You need to catch this, you can't test for this in the Execution State, because if the user has installed, and then uninstalled your application straight away, but then decides to install it once more, in the same instance, then your "In Browser" application will believe you are detached when you are not.

Exceptions (badly), if you detach and you are not detachable

If you attempt to detach (via code), and your application is not detachable (you didn't setup the xml in your manifest).  SL3 will throw a big wobbly, be careful.

Silverlight: Out of Browser Videos

So I've posted a couple of videos, on working with the new Silverlight 3 Out of Browser feature.

These videos are less than 10 minutes each, so hopefully should be quite short.

Part 1: Shows you how to make your Silverlight 3 applications "Out of Browser"

Silverlight 3 OOB 1

Part 2: Shows you how to track if you have a network connection, what happens if you are working offline, and how to track if your application is installed as "Out of Browser"

Silverlight Out Of Browser Part 2

I'm sure I will do more videos

Silverlight: Out of Browser, uninstalling doesn't update execution state

So lets say I have my Silverlight 3 application, and I decide to run my app "Out of Browser".

The Execution State allows me to determine if my application is detached (i.e. installed as an Out Of Browser application, or Running Online, there are some other states)


As soon as I install my application as an out of browser application, then both my "In Browser" and "Out of Browser" can detect that my application is detached (i.e. is installed as out of browser).

However if I then subsequently uninstall my "Out of Browser" application, the "In Browser" application is not notified of the update, and still thinks I am in the detached state.  This state isn't refreshed until I reload my Silverlight application

Silverlight: GetIsNetworkAvailable doesn't capture working offline

The new Silverlight 3 feature call:


will tell you if your machine as an available network connection.

This allows you to determine if your application is running disconnected from the network (e.g. on a network connection).

One of the purposes of this call is to allow you to decided if you need to store data to isolated storage and sync back to the server later, or if you can sync with the server just now.

However be aware, if you have set your browser to "Working Offline", GetIsNetworkAvailable will not take this into account.

Last night at NxtGen – Doing software large

Last night I had the pleasure of watching an absolutely fantastic presentation in Cambridge UK.

We had Alisson Sol of Microsoft Research (who used to work in the product teams at Redmond).  He gave the user group, a very frank, very entertaining presentation on developing software in large companies (specifically Microsoft).

We also got a great insight into how things work at Microsoft.

A big thanks to Alisson for this great presentation

Monday, 16 March 2009

Mix is nearly here

The blogging frenzy will resume shortly :)

Tuesday, 3 March 2009

Google Chrome the Resource Hog

On my little netbook, I run Google Chrome rather than IE6 as my web browser (IE6 is the default, and I don't really want to put IE7 on due to various reasons).  Google Chrome is extremely fast on my netbook and i have a good browsing experience, it definitely seems much better than IE6.

I have started to notice that just running Chrome takes on average between 5-10% of my CPU time just for it to sit there.  That's an awful lot of CPU time for having a browser window open (that is essentially doing nothing).  I think it's time to change browser.  I might give the new Safari Browser a go.

Silverlight: Register for DDD South West

Go! Quickly! Stop reading this and register now! Registration for DDD South West is now open. Be able to tell your grandchildren that you were there at the very beginning. Remember, there can be only one first time.

DDD South West is a free one day technical event on Saturday 23rd May 2009 at Queens College, Taunton with 13 top speakers providing 19 technical presentations

I'll be doing an Azure talk, Richard Costall will be doing a Silverlight talk (including some SL3), plus loads of more great talks.

Sunday, 1 March 2009

Silverlight: DDD Belfast - A peek at Silverlight 3

So a big thanks to everyone who voted for my session.  I feel very honored that my session has been voted in.

So if you are interested in Silverlight 3 and in Belfast on the 4th of April (a saturday), then I will see you there.

For more info on DDD Belfast, click on the link

Silverlight: At the MVP Summit in Seattle

So I'm at the MVP Summit in Seattle.

If you wanna say hello please do so.  I always wear a Hawaiian shirt at conferences, so I'm pretty easy to spot.

Anyways, this is gonna be a great few days, and looking forward to meeting lots of great folks