开发者

AlternateContent question

In xaml code I want to use certain buttons for instance or not based upon the whether there is a certain preprocessor attribute defined. So I'm trying to do a preprocessor thing in the xaml.Sorry this might not be compilable but it's a pretty simple example.

What I want to do is in the AssemblyInfo.cs for the project that the .xaml code resides

#if A_PROJECT
[assembly: XmlnsDefinitionAttribute("A_PROJECT", "A.PROJECT.NAMESPACE")]
#endif

#if B_PROJECT
[assembly: XmlnsDefinitionAttribute("B_PROJECT", "B.PROJECT.NAMESPACE")]
#endif

IN THE XAML

I want to use AButton if A Project other wise I don't want t开发者_StackOverflow社区o use this button in view

   <Button x:Name="AButton"/>

I tried using the following but I get compile error trying to reference buttton

   <mc:AlternateContent>
      <mc:Choice Requires="a_project">
         <Button x:Name="AButton"/>
      </mc:Choice>
   </mc:AlternateContent>

IN THE XAML.CS

There is a compile error trying to reference button


You have to surround your AButton code in *.cs files with:

#if A_PROJECT
    //AButton code
#endif
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜