Design-time-only background color in WPF?

There’s an undocumented property d:DesignStyle of type Style that you can set on a user control. This style is only applied in the designer and is not used at runtime.

You use it like this:

<UserControl ... d:DesignStyle="{StaticResource MyDesignStyle}" />

Or like this:

<UserControl ...>
    <d:DesignerProperties.DesignStyle>
        <Style TargetType="UserControl">
            <Setter Property="Background" Value="White" />
            <Setter Property="Height" Value="500" />
            <Setter Property="Width" Value="500" />
        </Style>
    </d:DesignerProperties.DesignStyle>
</UserControl>

The Background property is what you asked for. The Height and Width do replace your d:DesignHeight=500 and d:DesignWidth=500 in the <UserControl> tag. Then you have all your design properties at one place.

Note however, that any value set on the Style property (the one used at runtime) will also override the DesignStyle in the designer.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)