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
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>
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"/>