WPF Tutorial - A Simple Twitter Client

This tutorial will be broken down into several different parts to serve as a reference highlighting various features of WPF and C# programming.  I started this example just to play around with some simple animations and to figure out how to trigger the animation of one element from an event fired on another using only XAML, but I decided that it could also be a good “quick answer” reference to a few other common tasks if I made it actually do something (though it admittedly doesn’t do much).

A few of the topics I’ll provide examples of are data binding in WPF, downloading data from the web using Basic HTTP Authentication, XAML “Stylesheets” as StaticResources, WPF DataTemplates, WPF Triggers, and some basic animation of UI elements in WPF (and a simple LINQ to Objects query thrown in for good measure).  My goal here is to use the simplest possible solutions for each problem so anyone can easily reuse them in their own projects with the least amount of work.

The end product will look something like the following:

Here are the links to the individual topics:

Part 1 - Setup and the default WPF project files
Part 2 - A word about layout containers
Part 3 - Styling the UI and cleaning up with Resource and ResourceDictionary
Part 4 - Making a hidden preferences panel with Transforms, Triggers, and Animations
Part 5 - Downloading data with WebClient using Basic HTTP Authentication
Part 6 - Customizing a ListBox UI with DataTemplates

Parts 3, 4, and 6 should be the most useful and really highlight what makes WPF so cool (to me at least).  Several different platforms have introduced some form of declarative XML UI technology with a way to wire up some code to it, but WPF could easily be the most flexible and feature-rich of all of them.  What you may not notice but should definitely be aware of is that WPF doesn’t just come with a new look and a new API, it actually dramatically increases performance by offloading as much of the rendering work as possible to the video card.  This is something that Mac OS did much earlier and has been a source of criticism for desktop apps running under Windows.

Parts 3 through 6 include source code for the application at that particular step. Here are the links to download the source code and Visual Studio 2008 solution files for each of them:
TwitterExamplePart3.zip
TwitterExamplePart4.zip
TwitterExamplePart5.zip
TwitterExamplePart6.zip

Continue to Part 1 to set up our sample application…

  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • description
  • Furl
  • LinkedIn
  • Live
  • MySpace
  • Ping.fm
  • Reddit
  • Technorati
  • TwitThis

8 Responses to “WPF Tutorial - A Simple Twitter Client”

Leave a Reply