Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
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

VB
#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

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
 
Share this answer
 
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.
 
Share this answer
 
No,
both of them will run on different framework so we cannot use the same XAP for both.

Regards
siraz
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900