最后放弃了 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 -->