AlternateContent Tags causing issues with IDE, but not compiler

前端 未结 2 1752
忘掉有多难
忘掉有多难 2021-01-04 02:23

I am working on a legacy product. I need to make regions of a complex UI optional, based on build constants. It is not feasible to move these regions into controls, so I a

相关标签:
2条回答
  • 2021-01-04 02:50

    What about this:

    public class BuildConstants
    {
        public bool IsDebug
        {
            get
            {
    #if DEBUG
                return true;
    #else
                return false;
    #endif
            }
        }
    }
    

    and the 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>
    
    0 讨论(0)
  • 2021-01-04 03:08

    A little late to the party, but if you add the mc tag to your Ignorable attribute the error goes away. Your content won't show in the designer but worked for me when I compiled the different flavours of my project.

    <UserControl...
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:conditional="defined-in-assembly.cs"
        mc:Ignorable="d mc"/>
    
    0 讨论(0)
提交回复
热议问题