So I was writing my first entry in the 4C series when it came to me: I don’t think I’ve given a proper introduction to WPF. Well at least not since it was fully released. Although there are a million places one could go to get a quick overview. I figured it wouldn’t hurt to make that a million and one. So without further ado, I give you my dear reader:
A No-Holds-Barred Marketing Free Overview of WPF
What is WPF? It is a simple question, but the evidence suggests that it is not such a simple answer. On the official WPF Community Site, Microsoft provides a WPF overview presentation in four varieties 1, 3, and 5 slide, and 1 hour. Here’s the simple synopsis: the Windows Presentation Foundation is a framework that provides support for the presentation layer of a Windows application.
Yes I know what you’re thinking: doesn’t Windows Forms already provide a full day’s supply of my application’s UI needs? Well yes and no. There are many applications that can do just fine with what windows forms provides. But there are definitely more capabilities of Windows that can fall under the "presentation" umbrella other than forms, buttons, labels, and textboxes. In order to tap into those other capabilities, a developer needed familiarity with other APIs like DirectX and GDI+. This led to a lot of the rich visualization that Windows is capable of not being used by line of business app developers who, rather than taking the time to learn and utilize complex frameworks, felt their efforts would be better put to use in creating functionality rather than "prettying" up their UI. WPF takes the power normally wielded by DirectX and GDI specialists and makes it more accessible.
Okay, maybe that wasn’t as marketing free as I anticipated. At least I didn’t use "paradigm" or "ROI" or "TCO". Essentially WPF takes all of the disparate Windows APIs that could be used as part of an applications presentation and puts them in a single package. And that package just happens to be at the center of the new .Net Framework. Microsoft highlights the importance of WPF by starting its packages with System.Windows (whereas the Winforms packages begin with System.Windows.Forms).
In addition to the new framework, Microsoft has provided a new XML-based language (yes it’s an eXtended Markup Language based Language) called XAML (eXtensible Application Markup Language). That’s fine and dandy, but to top it off Microsoft created a compiler that can interpret XAML and create runtime objects from it. XAML can be used by itself or with a code-behind (partial class to be precise) that serves the same purpose as an ASP.Net code-behind: handling events generated by the XAML using imperative code.
So What Does This Mean for Me?
There are several significant points here:
- WPF makes advanced presentation technologies easier to access.
- XAML provides a method to declaratively layout a desktop interface (similar to HTML for web apps).
- XAML layout can be separated from general application coding allowing designers to design the UI while developers code the logic.
- Line of Business desktop apps can now take advantage of rich visualization without compromising functionality.
- You get to take advantage of a new Paradigm in windows development that can increase your company’s ROI and lower the TCO over the life of the application. (Sorry…had to let my inner marketer out for a second).
Now that I’ve given a VERY high-level overview, let’s get to the good stuff. Up next…the Window.