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">...</Style> </d:DesignerProperties.DesignStyle></UserControl>
Note however that any value set on the Style
property (the one used at runtime) will also override the DesignStyle
in the designer.
I found that you can do one for yourself. Custom design-time attributes in Silverlight and WPF designer is a tutorial how to do it for both Silverlight and WPF.
My answer was found here: Black Background for XAML Editor. There are a number of choices including checking System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)
at runtime.