If you browse the source code for the New York Times Silverlight Kit, you’ll notice that there are two project that are not for Silverlight but for WPF applications.  It turns out that most of the code that will work in Silverlight will work in WPF applications as well so it took me about 20 minutes to build the NYTimesWPFKit.  the WPF Kit links to the source files for the Silverlight kit so the two kits are actually sharing code.

image

Here are the differences:

  • WPF doesn’t have a JSON parser so the Times Articles and TimesTags APIs will not work in WPF but since the New York Times has made most of their APIs available via XML as well as JSON APIs, all the rest of the APIs work fine in WPF.
  • Some APIs are different, like HtmlPage and BitmapImage, so there are a few places that the code looks like this in the NYTimes.Newswire class Logo property:
#if SILVERLIGHT
        image.SetSource(streamResource.Stream);
#else
        image.StreamSource = streamResource.Stream;
#endif

The significant aspect here is that the WPF and Silverlight kits share 99% of the same code (I didn’t do the exact calculation but if you look a the source code you’ll see what I mean).