For various reasons, I’ve been spending a fair bit of time over the last week or two ramping up my Longhorn development skills; expect to see a few blog entries over the next fortnight or two on the subject as I write up some of my experiences.
Some of my early experimentation has been with the Longhorn sidebar. It’s not a bad place to start in some ways: it’s a new Longhorn feature, it exercises Avalon as well as optionally Indigo and/or WinFS, it has a built-in template as part of the Longhorn SDK, you can build it in manageable lumps and iteratively improve it.
The first tile I’ve created has been a quick note-taking component that allows you to enter an item into OneNote. I’ve become a big fan of OneNote over the last few months: it works well as a general dumping ground for all kinds of things I want to capture. There are a few idiosyncracies (for instance, navigation is hard with 200+ note pages), but for a V1 product it’s got plenty to keep me hooked. Anyway, the itch I was scratching with this OneNote tile was the ability to quickly jot down a phone number or some other tiny snippet of information and log it without having to even change window.
I’ll write more about the tile itself in a future article, but for now I just wanted to share a few tips about developing sidebar tiles in general.
To start with, you should know that (in the PDC and WinHEC builds, at least) the sidebar is part of the main explorer.exe process. As you are undoubtedly well aware, Longhorn is very actively under development still and is at best alpha-quality software at this stage. (In practice, it’s fine even now as a secondary machine – I run Outlook, VS and IE quite happily on it when I’m developing.) However, I had to rebuild my Longhorn partition early on this week when I built a buggy tile that caused the process to die with an unhandled exception. Since Explorer (and my tile) are loaded when the machine starts, I was caught in a nightmare scenario. I’d put good money on the sidebar being entirely robust against this kind of problem in later builds: it’s just one of the many things you have to put up with when you ride the bleeding edge.
If you get into this situation, you might be able to recover by deleting the registry keys that register your tile with Explorer: they’re found in a GUID-named subfolder of:
(you can search through them until you find the one that matches your assembly). In my case, even that didn’t work – so it’s possible something else I did got the machine into its terminal state.
The problem is that creating the XAML user interface for a tile by hand is (for me at least) a laborious and error-prone process. So the other piece of advice that was very helpful to me was something buried deep in the excellent Longhorn Development FAQ, under the topic “How do I debug a Sidebar Tile?” Here Rob Relyea provides an alternative project file for loading a sidebar tile as a separate NavigationApplication window, which means that I can happily write buggy crash-prone code all day long without ever worrying about it affecting the integrity of my platform. This is a good starting point, but it doesn’t fully model a hosting contanier for a sidebar tile: for example, there’s no support for tile backgrounds. I found myself using this separate project file to model the UI with trial and error; when the UI was complete and exception-free, I moved across to the real sidebar for ongoing development.
A couple of the most useful resources I found in building this tile were:
- Dino Esposito’s article (based on the PDC build – be prepared to swap some SimpleText elements for Text elements and make a few other minor amendments)
- The PDC lab “Using Controls, Layout and Data Binding” (available here as a 25MB MSI file) had some of the best examples of writing real-world UI code with XAML – no more rotated list boxes, please!
- The online Longhorn SDK is of course one of the best reference sources, if it covers the object you’re looking for…
I’ll write again soon on this topic as soon as I’ve got my tile into a good enough state that I’m prepared to show it in public!