Archive for March, 2007

ChatBlender

Tuesday, March 20th, 2007

ChatBlender is a Messenger add-on that allows you to share and preview WPF/e formatted XAML right inside the messenger window. It’s like XamlPad (or Kaxaml) for Messenger. I’d like to say that this was my idea, but I get to say the next best thing: it’s an IdentityMine invention! This is a really useful little tool, especially for collaborating on a design or passing XAML assets around for iteration or hand off.

SystemDropShadowChrome

Friday, March 16th, 2007

During a training session this week, someone asked about creating a dropshadow.  That reminded me of a useful, but somewhat hidden way of creating decent looking dropshadows in WPF without paying the price of using BitmapEffects. 

As you know, the most straightforward way to add a dropshadow to any content in WPF is to apply the DropShadowBitmapEffect.  That’s a very cool way to do it and it makes a pretty nice dropshadow (and offfers a fair amount of customization).  Unfortunately, though, there are some pretty serious performance tradeoffs to using BitmapEffects and because of that, we almost never use them.

We ran into this perf issue when we were creating the dropshadow for a lot of the system controls.  Most of the popup controls (Menu, ToolTip, ComboBox, etc.) need a dropshadow and (much to my dismay) BitmapEffect just wasn’t cutting it.  That’s where SystemDropShadowChrome enters the story.

We created it to emulate the system drop shadow but in a performant way.  It’s a decorator (like Border) that takes one child.  It basically draws a fuzzy-edged rectangle and then places the content on top it (with an offset).  If your content happens to be a rectangle things look pretty good.  Even if your content is rectangle with rounded corners, you can pull off a pretty good effect.  If your content is, say, an ellipse, well, you’re out of luck.  Here are some examples:

You only get two properties: a Color property (which actually is a Color, not a Brush) that let’s you change the color of the shadow, and a CornerRadius property that you can use to round off the corners on the dropshadow.

The good news is that this thing has pretty good perf.  It’s just a bunch of drawing commands and gradients and all of it gets rendered in code in the OnRender override of the control.

SystemDropShadowChrome is in the Microsoft.Windows.Themes namespace.  We tucked a lot of little gems away in this namespace.  Basically anything that we needed to pull off a visual effect in the system themes, but which didn’t make sense as a first-class element in the platform, got tucked away in there.  Everything is available for your tinkering pleasure.  You’ll have to import the namespace though (and add a reference to one of the theme assemblies).

If you want to experience SystemDropShadowChrome in person, you can download a project here.

Long Time No Post

Friday, March 16th, 2007

Enough said.  I know this and you know this, but let’s just move on.  I realize that my committment to the blog has a tendency to wax and wane a little, but right now it’s waxing.  So I’m just going to roll with it.

Blend RC Samples: Wow!

Friday, March 16th, 2007

If you haven’t installed the Blend Release Candidate, do it now.  You’re already behind the inspiration curve.  I’ve seen everyone blogging about the samples that ship with the new version, but until you use them, you really can’t know how nice they.  They really set a new bar for visual polish and fun interaction in WPF.  I’m not certain (I’d love to know for sure), but I’m guessing that these are the work of Celso Gomez.  Nicely done Microsoft!