More thoughts on WPF
Hi, my name is Eric, and I am a coding addict.
When I founded SourceGear, I was a programmer. Nine years later, my company has turned me into a marketing guy. After all the sacrifices I made to get this company going, it has coldly turned its back on me, ignoring my once prodigious programming talents, callously replacing me with people who are younger and better looking, watching apathetically as my technical skills atrophy each year, forgetting all the great things I have done, and ---
Ahem. Sorry, I got a little off track there. :-) Where was I?
Ah yes, my addiction. You see, although my company has grown to the point where it can no longer find a place for me as a coder, I have found it rather difficult to stop. I've got some sort of an addiction, a disease which compels me to write code. It is this mania which has driven me to write things like my solitaire game and my blogging app. I pretty much always have some kind of a hobby project going on.
Lately my hours as a compulsive coder are spent working on some ideas for woodworking design software. Since most of my readers are interested in neither woodworking nor solid modeling, I'll spare you the gory details.
About five weeks ago I published a few of my early thoughts on WPF (Windows Presentation Foundation, formerly called "Avalon"). My interest in WPF continued to grow, so recently I decided to give it a try by writing a WPF front end for my woodworking software. In the process of doing so, I am becoming a WPF fan.
The screen shot below is a picture of my WPF viewer in action:
Basically, my woodworking software is designed around the concept of a list of steps. Each step corresponds to one woodworking action, such as cutting a board or attaching two boards together. A primary job of the software is to draw a picture of how the project will look at each step.
In the screen shot above, the ListView on the left contains all of the steps to build a simple bookshelf. The larger 3D picture on the right is showing the currently selected step.
I am certainly still not an expert on WPF, but here is what I like so far:
- It is so easy to put cool things into a ListView. In
Win32, list controls are very oriented toward text. WPF has no such
bias. I wanted my ListView control to have a little preview picture of
each step. This was really simple to do with WPF.
- WPF 3D is far simpler to use than Managed DirectX.
That's kind of a remarkable thing to say when you consider that Managed
DirectX is far simpler than using DirectX from unmanaged code. I
was able to get excellent results from the 3D features of WPF in very little
- Obviously, there are tradeoffs. For example, I haven't
found a way to do volumetric textures using the 3D features in WPF.
Still, those tradeoffs seem worth the trouble.
- I haven't tried it yet, but apparently WPF is supposed to
be able to print my 3D stuff. That's a pretty big win, since I
expected printing support to be a heckuva lot of work.
- I have found XAML to be very nice, after I got past the
initial learning curve. At first, XAML looked like a bunch of nonsense on
my screen. It didn't take too long to find myself just typing tags and
- The Visual Studio support for WPF and XAML is more useful
than I thought. The visual UI designer is basically useless, but
installing "Cider" also adds other WPF support to Visual Studio 2005,
including special project actions and Intellisense.
- The WPF samples in the Windows SDK are quite helpful.
- The WPF documentation? Not so much.
- Since everything in WPF is built on DirectX, controls and
3D stuff don't seem to mind sharing the screen with each other. When I
was using Managed DirectX with Windows Forms, I couldn't find any easy way
to have my 3D view show up in the same window as my controls. With WPF,
this is trivial. As the screen shot shows, I have my Viewport3D in the
same window as a couple of ListView controls.
- Finally, here is the coolest example of how smooth this
- The preview pictures in the ListView are actually not
pictures -- they are little Viewport3D objects.
- With the Trackball class from Daniel Lehenbauer,
I can use the mouse to rotate and zoom the model.
- I have hooked up all the little viewports in the ListView
to the same Trackball as the main view. So, when I rotate or zoom the
model on the right, those little previews in the ListView are
automatically updated as well.
- This is what I call Deeply Neato. It's easier to appreciate when you watch it happen, so I captured a short movie (4.5 MB AVI, 12 seconds).
Anyway, I suppose I will soon bump into some sort of a wall, but so far, I think WPF is really nice.