Single source code base for Silverlight and WPF solutions

At Mix08, several people asked me about the possibility of creating a single source base for both WPF and Silverlight.  The scenario folks had in mind was to provide a reach solution with Silverlight that hits *ALL* possible users while also offering a really rich solutions for some users on full WPF (.NET Framework 3.0 or 3.5). 

This is a clear benefit of the Microsoft Ux platform.. We have worked hard to get a smooth continuum between WPF and Silverlight... Basically if it works in Silverlight you should be pretty sure it will work on WPF. 

I was chatting David Anson (one of the developers of the Silverlight 2 controls) and he mentioned that the shipping versions of ListBox and ScrollViewer were written this way!   That is right, to test out the continuum message, David built ListBox and ScrollViewer for Silverlight in such a way that the run (and past unit tests) on both WPF and Silverlight.  

Now, in and of itself, this is not all that interesting, because WPF already has a ListBox and ScrollViewer, but it does serve as a nice test case to demonstrate how you can build controls and applications that work on both Silverlight and WPF. 

image

Because we shipped the source and unit tests for the Silverlight controls, you can check this out yourself

In addition, David did a nice blog detailing the work he did and why and posted the test project you can try out as well. 

On a related note, be sure to check out the final step of ScottGu's Silverlight 2 tutorial...  Notice how easy it is for him to make a WPF application out of it.