Some helper code I've ended up using in a few of my Windows Phone apps.