【问题标题】:How to have a generic.xaml for Silverlight 3 and Silverlight 4?如何拥有 Silverlight 3 和 Silverlight 4 的 generic.xaml?
【发布时间】:2011-07-21 06:12:41
【问题描述】:
【问题讨论】:
标签:
silverlight
xaml
conditional
compilation
generic.xaml
【解决方案1】:
最后放弃了 XmlnsDefinition 和 XmlnsPrefix,因为我无法让它们正常工作......在 WPF 应用程序中很有趣,设计器窗口可以解析引用,但编译器不能......去看看。
我使用博客中的 cpp 预处理器解决了...
http://blogs.msdn.com/b/blemmon/archive/2009/04/29/using-the-preprocessor-to-share-incompatible-xaml-between-sl-and-wpf-part-1.aspx
我修改了 PreprocessXaml,只修改了 generic.xaml。
<Target Name="PreprocessXaml">
<ItemGroup>
<!-- Convert the DefineConstants property into an ItemGroup -->
<XamlConstants Include="$(DefineConstants)" />
</ItemGroup>
<PropertyGroup>
<!-- Convert the XamlConstants ItemGroup into a list command line switches for CL.exe -->
<CommandLineDefineConstants>@(XamlConstants->'/D%(Identity)',' ')</CommandLineDefineConstants>
</PropertyGroup>
<!-- Run the preprocessor -->
<Exec Command="CL.exe /nologo /EP $(CommandLineDefineConstants) "Themes/generic.i.xaml" > Themes/generic.xaml" />
<!-- Replace the pages with the preprocessed pages so that subsequent targets will use the preprocessed files -->