Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: XAML WPF Silverlight
It there a way to make the same xaml document be different depending on whether it is used in a WPF app of a Silverlight one.
 
in C# one can do the following
 
#if !SILVERLIGHT
  //Some code
#else
  //Some different code
#end if
 
Is there a way to do the equivalent in Xaml.
This would be very useful if one uses same xaml file in both WPF and Silverlight projects.
 
I suspect the answer is no, but I thought it worth asking.
Thanks
Ken
Posted 29-Jul-10 23:29pm
KenJohnson32.2K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You are right, the answer is "no".
 
The following article offers a workaround, although it's a bumpy way to go...
 
http://blogs.msdn.com/b/blemmon/archive/2009/04/29/using-the-preprocessor-to-share-incompatible-xaml-between-sl-and-wpf-part-1.aspx
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

No, but you can write conditional code in the code behind that sets styles or in converters that set properties.
 
We don't have conditional stuff in our code, but pretty much the entire layout/content is determined after reading database settings, and that's how we do it.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

No,
      both of them will run on different framework so we cannot use the same XAP for both.
 
Regards
siraz
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 18 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100