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.
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.
Comments
Anonymous
March 11, 2008
Not if you use the DataGrid in SilverLight where is that in WPF? Or the WatermarkTextBox? Yes only if Silverlight is a TRUE subset of .NET. I understand that SL 2.0 is beta and beta can have things that are not prime time. But when SL 2.0 goes live are we going to have controls in WPF that are not but are in SL 2.0?Anonymous
March 11, 2008
Not if you use e.Handled to stop propagation of a routed event...Anonymous
March 11, 2008
Where are the controls at ? Or is it just a movie player and gradient builder ?Anonymous
March 11, 2008
>> Not if you use the DataGrid in SilverLight where >> is that in WPF? Or the WatermarkTextBox? Good call... we are missing some controls in WPF right now... we are working on addressing that... look for more information on that soon.Anonymous
March 11, 2008
>> Where are the controls at ? The current set of controls are in the Silverlight 2 SDK.. more information here: http://blogs.msdn.com/brada/archive/2008/03/05/silverlight-2-controls.aspxAnonymous
March 11, 2008
I noticed that Scott mentioned in his "fix up the xmlns" that the namespace difference might be cleared up. If that is done, any hope for creating Assemblies that can compile both Silverlight and full .NET assemblies from one codebase. I'm currently tricking VS.NET into letting me share classes between assemblies (follow the link above for the how), but that method would be seriously tedious for sharing Controls between Silverlight and WPF.Anonymous
March 11, 2008
At Mix08 , seAnonymous
March 11, 2008
This is so far from reality it's just not funny. Maybe in beta 2 this will be possible, but there are so many fundamental things lacking in SLB1 that people are just used to in WPF that it isn't. Even down to the way things are defined in XAML - where's {x:Type} ? How do we have a generic.xaml for a control library for compiles for both platforms? You simply cannot.Anonymous
March 12, 2008
Sharepoint SharePoint Slipstreams recently announced [Via: slennon ] WPF Usability Design For Forms:...Anonymous
March 17, 2008
Infragistics is one of the major ISVs developing controls for Microsoft platforms. I favorably reviewed their NetAdvantage controls for ASP.NET for InfoWorld in 2006. They have also released controls for Windows Forms and Windows Presentation FrameworkAnonymous
May 18, 2008
This is actually not as convenient as it sounds. Suppose I have a project with 250 c# files in it, which compiles fine in silverlight. Now I want to compile it in WPF, I have to open the project file to change all the references, and recompile. If this sounds tedious, it gets worse when maintain this project, add a new file, remove a file ... etc. Keep the 2 project files in sync is a pain in neck. Any easier ways?