I’m taking a break from XNA (not really - my poor brain just couldn’t handle the switch from event-driven ASP.NET to the ever-important game loop) and have decided to take a glance at another new and nifty technology Microsoft has been touting: the Windows Presentation Foundation (WPF).
But after some initial reading over at MSDN, I still couldn’t get my head around what it is. Perhaps the wordiness of a sentence such as “a next-generation presentation system for building Windows client applications with visually stunning user experiences” just made my brain shut down. I don’t know about you, but whenever I hear things that sound like marketing gimmicks to me, I tend to ignore it. Especially lines that use adjectives like “next-generation” and “visually stunning”. And I got that from a technical site.
Still I plodded on, because I know that when Microsoft is pushing something as “next-generation”, you have to stand up and listen.
I saw a better introduction to WPF and fortunately, it flicked the lightbulb switch in my head.
Here are a few points (some according to the text, some from other tutorials) that brought sense to WPF for me:
WPF is an API. Okay, the three-letter acronyms may have gone over people’s heads, but I’m a developer, so I understood that perfectly. Because when someone says something is a technology, that can mean many things - it can be the new iPhone for all I care. Now I know WPF is not just a piece of hardware or a killer program. It’s a framework I can use/program in to do something related to computers.
WPF creates graphical user interfaces. Many things create GUIs. WinForms is used to create Windows programs. On the web side, we use a bunch of stuff, but it all translates to HTML. The good thing about WPF is you can use it for both Windows clients or for browsers.
eXtensible Application Markup Language (XAML) does not equal WPF. That’s right, the new declarative language on the block (pronounced “zammel” - how odd) is not the WPF solely. Remember, WPF is the API. Part of that is the language/s used to code when you use the framework. And XAML is not alone there, it is only used to code the graphical side of things. When you still want to do the logic, you use good ol’ C# (or VB.NET, if you’re that kind)
Silverlight is WPF for everywhere. It’s not a coincidence that it was formerly known as WPF/E. Silverlight, or Microsoft Flash as I used to see it, is WPF when you use it NOT JUST FOR WINDOWS. You see, when they developed WPF, of course they developed it for Windows. What do you think the W stands for? But Microsoft obviously thought, “Hey, we have all this cool new technology - we should let everyone use it!” So they repackaged WPF, used the Web as the vehicle for “everywhere”, and out came Silverlight. So when you see Silverlight, don’t get shocked or confused or think that you’re being overwhelmed by all this new techs. It’s all based on WPF as well. To develop with it, you use the same things.
Microsoft Blend is the (Microsoft) tool to write XAML. Of course you can write XAML by hand. I do that with HTML (proud supporter of Notepad here!). But the beauty of this whole WPF thingamajig is that it brings developers and designers closer together. If you’ve worked with any piece of software, you know that after the project scoping and briefing comes concepts & design. The designer (I refuse to call them creative team - does that mean developers aren’t creative as well?) presents concepts to the client and if the client is satisfied, a concept gets approved. The work then gets passed to the developer. But wait! What’s this? We have a JPG file! (Or a PNG, or if we’re lucky, a PSD) The developer must now work their magic to transform that graphic file into a full-blown application. And along the way, the developer finds out that there’s just something that gets lost in translation. Not to mention the extra work that gets piled up on the developer.
With WPF (and XAML), designers can now do their magic using graphics software, or even use Blend from the start. Gone is the huge JPG file that gets passed on, because when the design is imported into Blend, XAML also gets done. That XAML, good sirs and madams, can now be transferred to Visual Studio, where the developers can go straight to work on the back-end logic, now that the front-end is good to go. This keeps the designers happy that their masterpiece won’t be touched by other masters.
Now that I got the answers for What is it, it’s time to go to How do I use it/What can I do with it?
I’m still working on that part (I have Visual Studio 2008 open right now!) but I can point you to tutorials and hands-on labs that are really promising.
As for studying WPF instead of the gaming framework, XNA, I guess I found it easier to grasp WPF because it’s the next step from ASP.NET. I don’t have to switch paradigms or anything. I’m still working with interfaces that respond to events. Game code is harder for me to think about as I have to think about the game always updating and rendering every second.
Oh well. That’s my next project.