Archive for the tag 'windowsforms'

Getting Started with WPF

image

I don’t know about you, but it seems more difficult to get started with Windows Presentation Foundation (WPF) than it should be. I’ve been dabbling with it for a while, but I recently wanted to build a client-side application to track my ongoing projects and decided to resist the temptation to pump out another Windows Forms app and use the experience to get familiar with WPF.

This post is my recommendation on the best way I’ve found to ramp up on WPF.

I’ll likely make a few of these posts as I continue to find valuable resources. One thing I want to do is make a simple screencast that shows how to make a standard business-style application. With all the whiz-bang things WPF can do, it seems that real-world examples are hard to find. I’m less concerned with the sexy graphics aspects (animation, gradients, etc.) and more with the fact that Microsoft is putting all of its resources behind this and my bet is most new client-side GUI innovations (controls, tools, patterns, third party support) will happen here, not in WinForms.

Who are these posts for?

It will help if you are exactly like me! :) Who is that?

I’m starting from a strong background in .NET. By that I mean all technologies considered part of .NET 2.0. I have dabbled with the 3.0 technologies (WCF, WPF, LINQ, WF, etc.) but I am still ramping up on those. This means I have a good working knowledge of XML (which is a considerable help with WPF where most tools don’t talk code — they talk XAML).

I’m not a creative-type person. There is no doubt that designers love WPF and the designer-coder workflow is much better than it was before, but I won’t concentrate on design here. Also, “user experience” is a big part of WPF, but I’m just not approaching it from that angle yet.

Also, I tend to learn better by video, screencasts, and real code rather than articles. So, the resources below are weighted towards non-text.

Basics

  • WPF is the new (well, 2 or 3 year old) client-side development story for .NET. Windows Forms still exists, but from what I’ve seen any new development should strongly consider switching to WPF (see above). There are a few things missing that we have in Windows Forms (like a DataGrid/GridView) but those and much more are on their way (see this video from MIX08 for upcoming improvements).
  • WPF takes full advantage of Microsoft’s new way to express .NET code in XML. It’s called XAML (here is an overview that is worth a glance but the resources below are better).
  • Most of these resources assume you have installed (at a minimum) .NET Framework 3.5. Download and install here.

Great Resources (How To Learn It)

This is my version of the most efficient path for learning WPF. After these you will have a good understanding of how WPF works and some great examples to explore.

  • If you’re at all serious, go ahead and buy WPF Unleashed by Adam Nathan. Don’t really read it end-to-end, but you will reference it constantly while using the other resources here. It is very well done. Read the Amazon reviews for more praise. Chris Sells and Ian Griffith’s book is also good, but not as clear in my opinion.
  • I would start with these fantastic WPF Bootcamp videos (actually, the ones here are newer versions of the same material although I haven’t seen them yet — see Karsten’s blog entry below for a individual download links). Watch the first three videos (the keynote, lap around WPF, and lap around Blend) to get an overview of what WPF is all about. By all means, watch these on high speed (see the first sentence in this post for how to speed up videos — I couldn’t easily get the embedded versions to speed up so download them if you want to speed them up).
  • This post by jfo is a bit dated, but I found the attached Word document “WPF for those who know Windows Forms” to be a real gem (direct download link). It has information that I haven’t found aggregated anywhere else. Check the other links on that page, but that article is the great resource even if you aren’t coming from Windows Forms.
  • Watch the next two Bootcamp training videos by Ian Griffiths (or the equivalents in the newer videos). Really, really good. These will give you a solid base while whetting your appetite for some intermediate WPF functionality.
  • Kevin Moore’s Bag-o-Tricks (here) is bite-sized chunks of super cool WPF functionality. Tear into it, check out the code, and see how it works.
  • The Mix08 videos are largely for designers and the presentation layer. I haven’t seen any I would expressly recommend, but there is a lot of content here.

Other Resources

Most of these are highly recommended but they didn’t appeal to me like the Great Resources above.

Tools

Here are some tools that fill in the some gaps left by Visual Studio 2008 and WPF.

  • Microsoft Expression Blend - Awesome tool to develop WPF interfaces. It “blends” seamlessly with Visual Studio 2008 and makes design-time easier (general interface, animation, and lots more). It’s not free, but you can download the preview and beta versions for free. The latest as of now is the 2.5 March Preview (download here). Here’s some fantastic training videos for those interested in the design aspects of Blend.
  • XAMLPad (also see Kaxaml below) - A lightweight XAML editor where you can immediately see the results of your XAML. Kind of a sandbox for XAML like SnippetCompiler is for code. It comes as part of the Windows SDK. In my installation it can be found at C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin .
  • Kaxaml - This is easier to install and has many more features than XAMLPad, but you might want XAMLPad anyway to follow most of the examples on the Web.
  • Snoop - Visually debug and inspect WPF applications at runtime (Spy++ for WPF).
  • Xceed DataGrid for WPF - Until Microsoft makes a DataGrid control you are stuck building your own out of a ListView in GridView mode, borrowing the WinForms grid (yuck), or using a third party grid. Xceed’s grid works well and the express edition is free within some boundaries. Infragistics has one too but I usually have bad experiences with their controls and there is no free version that I can see (disclaimer: I have not tried the Infragistics grid).

Blogs

There are a ton of WPF blogs, but these few are relatively active and have been the most helpful to me so far. Warning: once you start reading these blogs you are on your way down a slippery slope into WPF mastery that will eat up all your time. :)

  • Scott Guthrie - Microsoft head of .NET development, so this is the source of it all.
  • Josh Smith - Great teaching style on a wide range of WPF subjects.
  • Kevin Moore - The Bag-o-Tricks mentioned above and other insightful posts.
  • Ian Griffiths - Great in-depth .NET articles (not all WPF).
  • Dr. WPF - Lots of great info. No offense to the Dr, but the formatting and layout is a bit rough. I prefer to read this one in my RSS reader.
  • Karsten Januszewski - WPF training info but also a good source of WPF news and events. Check here for the 2008 Bootcamp videos and information that I mentioned above.

At this point you should have a ton of other resources to check out. WPF is huge and there is a lot to learn, but these resources should give you a solid start with WPF. Comment below if you have found anything else remarkable.

I also wanted to point out this other Getting Started post by Karsten. I really like the content but it is getting stale and the links are breaking.