Joh*_*man 15 ide xaml visual-studio visual-studio-2012 visual-studio-2013
我正在研究传统产品.我需要根据构建常量使复杂UI的区域可选.将这些区域移动到控件中是不可行的,因此我使用AlternateContent Tags(mc:AlternateContent).
这在编译时非常有效,应用程序按预期运行.
但是,IDE为每个AlternateContent声明了一个错误,并且包含了Choice标签,并且不会加载设计窗口/预览(在VS或Blend中):
The name "AlternateContent" does not exist in the namespace "http://schemas.openxmlformats.org/markup-compatibility/2006"
The name "Choice" does not exist in the namespace "http://schemas.openxmlformats.org/markup-compatibility/2006"
我尝试过,重建,清理和重建,在发布,调试,x86,x64和重新启动之间更改构建设置.什么都没有帮助.它甚至在Blend中给出了相同的错误.
我希望这只是我正在做的蠢事,我可以解决它; 或者可能是我应该使用的更新的名称空间URI.如果我无法解决错误,我希望有人知道在IDE中抑制这些错误的技巧,所以可以使用它.
我有一个完全更新的VS2013 Premium安装.然而,它在运行VS14 CTP的测试机器上有一个小故障,另一个运行VS2012(完全更新),两者都没有任何插件; 所以我不得不认为我的电脑安装不是问题.
小智 9
派对有点晚,但是如果你将mc标签添加到Ignorable属性,那么错误就会消失.当我编译项目的不同风格时,您的内容不会显示在设计器中,而是为我工作.
<UserControl...
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:conditional="defined-in-assembly.cs"
    mc:Ignorable="d mc"/>
那这个呢:
public class BuildConstants
{
    public bool IsDebug
    {
        get
        {
#if DEBUG
            return true;
#else
            return false;
#endif
        }
    }
}
和 xaml:
<Application.Resources>
    <BooleanToVisibilityConverter x:Name="BooleanToVisibilityConverter"></BooleanToVisibilityConverter>
    <l:BuildConstants x:Key="BuildConstants" />
</Application.Resources>
<Grid Visibility="{Binding IsDebug, Source={StaticResource BuildConstants}, Converter={StaticResource BooleanToVisibilityConverter}}">
    <TextBlock Text="This will be visible only when DEBUG build constant is present"></TextBlock>
</Grid>
| 归档时间: | 
 | 
| 查看次数: | 1289 次 | 
| 最近记录: |