Zoom or doom?
It’s been a busy, frustrating, yet interesting and rewarding time these past couple of months. It all started when I decided to write my own “Deep Zoom” web application using Silverlight, as I promised in my last column. Sometimes with early beta code, waiting a couple of weeks before you start pays off, and this was the case for me. I expected to have to write mouse event handlers so the user could zoom and scroll around the image, but while I was still pondering this, a new version of Deep Zoom Composer was released that wrote all that code for me, and built a Silverlight 2 project to boot!
“Excellent,” I thought, “this project is going to be a breeze.” A project using an early beta technology with beta programming tools – what could possibly go wrong? Just about everything, actually. Like complete reinstalls of Visual Studio Service Pack 1, the Silverlight add-in for Visual Studio and the Silverlight SDK. To fix one bug.
Even then, another bug – one that caused me two days of messing about – was still there. When you write a Silverlight application in VS2008, the design pane is a preview only, even though it’s called “Design” and the cursor changes when you try to drop a control onto it! This is a known bug that will be fixed in later builds, but what a lot of time it wasted, as I believed it was being caused by a bad installation of the tools.
You normally design Silverlight applications in Expression Blend, which was also updated from a March Preview to a June Preview as I was coding. Given all this chopping and changing of Silverlight, you might be wondering “why bother”? Well, Deep Zoom is one reason, and another is its data binding. Before you yawn at the prospect of Yet Another Microsoft Way To Access Databases, this time the binding really is different, honest! Data binding is built into Silverlight and WPF from the ground up, so that almost any object on a page can be data-bound either to a traditional database source or, more excitingly, to any other object.
What does this mean? Well, imagine you want a slider control on a page to alter the angle of an object, say a pointer on a dial. Previously, you’d have written some event code, so that when the slider changed you redrew the other object at the new angle. In WPF/Silverlight, you simply data bind the object’s “Rotate Transform” method to the value property of the slider – and it just works!
It was at a Microsoft demonstration by Josh Twist that I first learned about this use of data binding, and his presentation and code are available for download at www.pcpro.co.uk/links/168webapps. After this presentation, there was a real buzz among the audience, and lots of talk about what might be achieved using this technique. It made a change to see a developer produce nice-looking graphics while we watched, rather than muttering “I’m not a designer” and drawing a red square in a blue circle with a textbox to represent a UI. Come on guys, you have pre-written code snippets in your demos, so why not give us decent designs so we can see what can be achieved? All developers and designers know it’s the detail that sinks or floats a project. I’ll come back to this subject in a future issue, but in the meantime take a look at the working example at www.pcpro.co.uk/links/168webapps2.
This demo was one of many at the fun-filled Fest08, the annual event of the NxtGen user group (NxtGenUG). I was invited to the event by one of NxtGenUG’s founders, Richard Costall, whom I’d met in Vegas at the Microsoft Mix08 conference. This non-profit user group was set up in 2006, and currently has about 200 members. Its aim is to help developers stay up to date with the latest technologies coming from Microsoft (not a bad idea given the steady bombardment from Redmond). Where NxtGen tries to be different is the fun element that hallmarks its events: the atmosphere was relaxed and sociable unlike a lot of such “geek fests” I’ve been to. Oh, and to top it all off there was free pizza too! Check these guys out at www.nxtgenug.net: I decided to pay up and join, so perhaps I’ll see you there.