Search code examples
wpfvisual-studioxamlvisual-studio-2019xaml-designer

Is it possible to show hidden elements in XAML designer for WPF in Visual Studio 2019?


In WinForms designer hidden elements are still shown in designer, which makes perfect sense to me as I want to be able to edit and see the element without switching its visibility all the time. In WPF XAML designer visibility property hides the element completely. I absolutely cannot get the idea of this feature, especially because there is designer IsHidden directive, which let us control the visibility of elements in designer.

Is it possible to show hidden elements in XAML designer somehow?


Solution

  • You can try this:

    xmlns:cm="clr-namespace:System.ComponentModel;assembly=PresentationFramework"
    
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="boolToVisibility"/>
    </Window.Resources>
    <Grid>
        <Button Visibility="{Binding (cm:DesignerProperties.IsInDesignMode), RelativeSource={RelativeSource Self}, Converter={StaticResource boolToVisibility}}"/>
    </Grid>