Archive for June, 2007

Scrollbar with a Fixed Thumb Size

Thursday, June 28th, 2007

I thought I had posted this a while ago, but couldn’t find it today when someone asked me about it, so forgive me if this is a repeat.

You may have tried to do this, create a Scrollbar template where the thumb stays a fixed size, and then, like me, given up.  At least that’s what I did the first time I tried it when Karsten and I were working on a demo for MIX last year. 

Though not easily discoverable, it turns out that it is possible to do this.  The trick is in the Track control (a very inner part of both the ScrollBar and Slider templates).  Track has a tight relationship with ScrollViewer and even seeks out the ViewportSize property on a ScrollViewer on its own.  That’s how it knows how to size the Thumb.  If, however, you overrided the value for ViewportSize (on the Track, not the ScrollViewer) to be Double.NaN, then the track will leave the size of the Thumb alone.

In other words, deep in the guts of the ScrollBar template, you have a Track control.  On that Track, you need to do this:

<Track ViewportSize=”{x:Static sys:Double.NaN} …

To get that to work, of course, you need to have mapped the System namespace to the prefix sys.  You can do that like this:

xmlns:sys=”clr-namespace:System;assembly=mscorlib”

Once all that is done, Track will leave the size of the Thumb alone.  At that point, make sure you give the Thumb a size, otherwise it will just disappear.

Here’s a SimpleStyle version of ScrollBar with fixed thumb.

Apple Design Awards

Thursday, June 14th, 2007

Check out the best in OSX software design for 2007 here.  As WPF developers, we’re fond of pointing out that all Mac software kind of seems the same, that Apple keeps you in a box.  Where’s the creativity?  I guess there is some truth to the fact that OSX has a very strong design “built-in” and it can be hard to break out, but these are creative apps!  I especially like Coda–it definitely pushes against the walls of that box.  The others may not be quite so playful and, in fact, may kind of look like other software on the Mac, but here’s the thing: they’re great apps and, in fact, people generally seem to appreciate the fact that they look like the other software on the Mac. 

Don’t get me wrong.  There’s a case to be made for the flexibility that WPF gives you and we’ve seen some amazing UI work in WPF, both visual and interactive.  I wouldn’t trade it.  I can only imagine how much work it was to get sticky tape and 3D previews in the Coda previewer, and that’s not much more than a day’s work in WPF.  On the other hand, most of us are still investing a lot of time reinventing the look of an app because, frankly, we still don’t want to look like Windows.  Aero is great, but it’s still left most of us opting out, not in.

Maybe it comes back to loving your software.  Mac people love the whole package and that includes the operating system.  So, to look like the OS is too be part of that thing that users love.  On the other hand, most of us still see Windows as something we just use.  So to look like Windows is to look kind of boring.  I honestly hope that Microsoft can change that.  In the meantime, though, since Windows users are keeping things “professional” with their OS we’ll need to create the love ourselves and WPF is great for that.