locked
XAML reuse between WPF and SL2 RRS feed

  • Question

  • Just how reusable is XAML between WPF and SL2? Is it guaranteed/promised/planned  that XAML properly rendered in WPF at least wouldn't break when compiled in SL2 application and XAML that renders in SL2 would always show up [almost] the same way in WPF?

    Friday, July 4, 2008 3:16 AM

Answers

  • Well, it should work, but like I said, no guarantees. We've tried really hard to make it work. The WPF compiler should be pretty good about telling you where there a problems.

    There are some obvious differences--if you use a Button you'll get a WPF button, not a Silverlight button. If you have VSM stuff in your XAML, that won't work right off the bat, but I believe we plan to address that.

    Monday, July 7, 2008 10:52 AM

All replies

  • Hi,

    No the XAMl used in WPF have window as root element ,But in Silverlight Usercontrol is the root element .Also most of the namespaces in wpf are related to windows developemnet.where in silverlight namespaces are related to silverlight developement.

    Friday, July 4, 2008 3:35 AM
  • Well, of course I meant reuse of the main part of XAML which is between UserControl and Window tags. I really didn't understand your comment on namespaces though... so what? let them be different - they shouldn't break the actual look/feel when moved around between WPF and SL2, should they?

     

    Could somebody give an example of XAML that works in SL2 but doesn't work [by design] in WPF ?

    Friday, July 4, 2008 3:46 AM
  • Yes some effect like bitmapeffect ,shaddow effect this kind of effect can not applied in silverlight but it is possible in Wpf.

    Friday, July 4, 2008 4:31 AM
  • Silverlight is a subset of WPF, so it will always be easier to migrate from Silverlight to WPF. We try very hard to make Silverlight XAML and code work in WPF. We have tools that grind through the APIs and report any differences. There are incompatilities but in most cases they are not a huge deal with the exception of things like the app model, which is different.

    Many of the Silverlight controls were actually originally developed in WPF, as Silverlight features that the controls needed were still being written. Then at one point you could compile the same source for either WPF or Silverlight (with a few #ifs) but now we don't try to make the control code compile under WPF anymore because we don't have time. But that's where they came from, anyway.

    Friday, July 4, 2008 3:17 PM
  • So, Dave, there's no guarantee that XAML code pasted from UserControl tag in SL2 app to Window tag in WPF app will work???Any indication what to look for then? What will break?

    Sunday, July 6, 2008 3:57 PM
  • Well, it should work, but like I said, no guarantees. We've tried really hard to make it work. The WPF compiler should be pretty good about telling you where there a problems.

    There are some obvious differences--if you use a Button you'll get a WPF button, not a Silverlight button. If you have VSM stuff in your XAML, that won't work right off the bat, but I believe we plan to address that.

    Monday, July 7, 2008 10:52 AM
  • Check http://www.sharpgis.net/post/2009/02/06/Silverlight-and-WPF-code-reuse-pitfalls.aspx Hope that helps :) Pooran
    Monday, June 8, 2009 9:24 AM