« TechEd BizTalk WCF adapter talk | Main | Not all hopscotch and conkers »
August 30, 2007
Should I use WPF for business applications?
The conventional wisdom -- and Microsoft guidance -- on "should I use Windows Forms or Windows Presentation Foundation for my business application" is to use Windows Forms. The justification is that WPF's novel features aren't sufficiently useful to line-of-business applications to balance out Windows Forms' better tools, control set and third-party support. WPF, it is implied, is only worth the candle if you're doing something amazingly fancy in the way of visual design: a "cool" app rather than a useful one.
I think this is nonsense.
It's certainly true that Windows Forms has the advantages people cite. But WPF has a number of features which should make it a serious option for anybody developing a new application, no matter how rudimentary the user interface. Skipping over nice tactical time-savers like layout managers and major but specialised features like navigation and styling, the big two of these are data binding and the rich content model, and particularly the way they work together.
A typical forms application is very data-centric. While Windows Forms 2.0 delivers substantial improvements to data binding over Visual Basic and WinForms 1.x, it's still relatively limited compared to WPF. Bidirectional value converters, multibindings, validations and the ability to bind non-primitive types are just a few of the features that make it easier to build data-centric forms in WPF than in Windows Forms, even if those forms are visually quite simple.
But in WPF there's no need for forms to be bald and textual. The rich content model makes it almost as easy to create simple visualisations as to display raw text. Sure, if you want elegant or complex visuals, you have some work to do, but in WPF you pay only for what you use: you don't incur the responsibility of having to draw everything from scratch just because you want one of the words on a button to be bold or list box items to be colour coded, or of having to implement all sorts of list control behaviour just because you want to display a collection in a format other than a stack.
This gets really powerful when you start harnessing data binding and the rich content model together. In Windows Forms, if you want to implement a complex visual interface such as a Gantt chart or a geographical display, you have to write a lot of code to draw the control, handle input such as keyboard and mouse input and manage the view data model (e.g. selection tracking). A WPF Gantt chart is just a list box with the items rendered as rectangles whose width is bound to duration and whose position is bound to their start time. Very easy to write, and things like selection management, arrow-key support and mouse selection come for free. (You have to do a bit more work to allow users to drag the rectangles, but once you've done that, hooking those UI events back to the underlying model is just a matter of making your data bindings two way.)
For me, the killer application of WPF is not bouncing buttons with dancing elves trapped inside them. The killer application is information visualisation, the kind of things you get from Tufte and the periodic table. And that's something that even forms-style, line-of-business applications will find worthwhile.
August 30, 2007 in Software | Permalink
TrackBack
TrackBack URL for this entry:
https://www.typepad.com/services/trackback/6a00d8341c5c9b53ef00e54ed4373d8833
Listed below are links to weblogs that reference Should I use WPF for business applications?:
» WPF for biz apps, or not. from WPF Team Bloggers
Flatlander writes that he finds WPF valuable for biz apps, despite our guidance that having less controls, [Read More]
Tracked on Aug 31, 2007 3:29:25 AM
Comments
Very well put! We haven't gone full-bore with WPF in our LOB app, but it is working its way in there. I can't agree more that it's really simple to do very crisp layouts as quickly as I could with Winforms. And the biggest advantage is that if you want to tweak the appearance of a control, just change the style. WPF is definitely business ready. It just takes a bit of courage to take that challenge.
Posted by: Mike Brown at Aug 31, 2007 5:32:56 AM
Another interesting battle for hearts and minds will be between WPF and Silverlight. Of course Sliverlight still has a lot of bulking up to do, but my impression from reading the Silverlight forums (http://silverlight.net/forums/) is that most folks aren't interested in it as just an eye-candy, Flash replacement. People want to do real, full blown apps with it and they aren't going to be satisfied with the single option of the sandboxed version. I imagine the pitch will be: "if you want full trust you should use WPF", but that may not sway most of these web-oriented customers.
Posted by: Alan Cobb at Aug 31, 2007 7:48:50 AM
Great Post! I'm currently working on my own series to list some of the reasons why (and why not) WPF is a serious contender for LoB Apps:
Posted by: Josh Twist at Oct 31, 2007 10:29:34 PM
How much does Microsoft pay you people to say this crap. And it always the same thing. Binding and Rich applications. Whoeee... WPF is crap right now. Meanwhile there isn't a single Lob out there. If there is, point it out to me. I dare you... You can't because there isn't any......
Posted by: Rob at Apr 8, 2008 8:58:50 AM
How much does Microsoft pay you people to say this crap. And it always the same thing. Binding and Rich applications. Whoeee... WPF is crap right now. Meanwhile there isn't a single Lob out there. If there is, point it out to me. I dare you... You can't because there isn't any......
Posted by: Rob at Apr 8, 2008 8:59:50 AM
Looks like user "Josh" and "Rob" are same and wish worked at microsoft... lol...
anyways, great artcile I agree with everything you guys just said. I am working on re-architecting a LOB VB/COM application used by 600 users at different geographic locations to .NET. My choice of UI is WPF.
Posted by: GajaKannan at Apr 25, 2008 1:46:03 AM
Dude, you are just writing for writing sake. If you do not need the power of WPF, the application is short-lived (a few years) and you need to get it done quickly and with less pain... Winforms all the way. The third party support, better memory management, more online help and books and better stability is worth not losing sleep over fighting with WPF. However, if you need the power of WPF and believe the application will last for a very long time, then WPF is worth consideration. WPF is way more powerful graphic-wise than Winform. My guess is that Microsoft may do away with Winform slowly like it is trying to do away with COM in favor of .NET. Its is not worth it for a single company to make two competing and overlapping products. The answer is as simple as thing if not simplier. Spare us the rhetorics that hide the simplicity.
Posted by: Green at Sep 24, 2008 4:55:34 AM
I'm currently working on Gantt chart too
http://softwaremilestones.blogspot.com/2009/08/blog-post.html
Posted by: roman at Aug 13, 2009 2:33:38 AM
@R0b:
Lawson has an incredibly powerful business app using WPF. Plenty of power there.
Posted by: Lew at Aug 26, 2009 6:17:35 AM
When I first started using WPF I absolutley did not like it. Why? Simple things like refreshing content we absent from code behind. But as I've read and learned more about it, I'm liking it more and more. The big Negative on WPF is that it is at least two times slower than Winforms. That inculdes the long, unexpected waits within the IDE at development time. I believe the big positive for WPF is that conversion to Silverlight should be a breeze. Unlike Java which allowed you to convert a "Form" to a "Web Based Form" easily, Winforms never really had that option. WPF does... I think for those of us developers in Windows Land it would be a good career move to know as much as you can about WPF.
Posted by: Mr. JavaMan at Jan 19, 2010 3:38:05 AM