Finally Onto WPF
I’ve been learning WPF for some GUI tools I’m building, and it’s a whole new world. I feel like I’m back with .NET 1.0 in the late 90’s trying to inhale a bunch of new technology and patterns all at once.
It’s pretty exciting, even if I am joining this game very late.
As I work in the WPF world (and maybe WCF and other techs as I start messing around with them) I’ll be posting odds and ends here about research I do and dead-end paths I go down.
Not WinForms++
The first thing I learned is that WPF isn’t WinForms++ or even “WinForms in XML”. It lives in an entirely different universe. Though, for folks like me that have been stuck in that old world too long, WPF is initially going to feel like a simple upgrade of an old framework. There are a lot of similar-sounding classes and concepts in the new framework. These are merely false cognates.
I’ve been learning that it’s better for me to enter into new WPF concepts like a 101 student: by reading books and MSDN docs. I haven’t done that in a while. Normally I just bang on code and refine, using Google and StackOverflow to guide my way (and surfclarity to filter out spam sites like experts-exchange.com). I’m still doing that as I pick up WPF, but adding on top of it some serious reading.
Pro WPF in C# 2008 (available at Safari where I’m reading it) is my current favorite book for learning WPF concepts. Most books I come across are lame reference manuals disguised as tutorials, or sensationalized drooling over new tech with no real experience to back it up. The author does great things like quickly explaining a cool-sounding WPF concept, then telling you not to use it and why. Not all of WPF turned out to be a good idea, after all.
So, here are some of the key benefits I’ve noticed in the short time I’ve worked in WPF:
Layout and Composition
The problem of control layout (wrap, dock, table, stretch, fill, and so on) is solved. It’s nice of WPF to catch up with where HTML has been for a while, though in a much cleaner and more internally consistent way. Later versions of WinForms started to get somewhere with TableLayoutPanel and friends, but it’s still the same old underlying framework, where you run into limitations very quickly.
WPF lets you easily nest any control within nearly any other, and has a sensible system for guiding layout containers (attached properties rather than Control-derived least-common-denominator properties). It’s simple, for example, to put a pair of icons and a few checkboxes into each element of a ListView, and make it look good. Virtualization is automatic as well, given certain constraints. Trying to make any of that work in old WinForms requires a lot of custom code.
Page 1 of 4 | Next page
