wpfvisual-studio-2010designer

Design-time-only background color in WPF?


In WPF XAML there is the convenient DesignHeight and DesignWidth, for instance in code as

<UserControl ... d:DesignHeight="500" d:DesignWidth="500" ... />

which is great because I can build the layout with a representative, but not locked-in, control size.

However, I'm often building dark UIs, where labels and so forth need to be white, but my controls still need a transparent background color. This creates a design-time inconvenience because white seems to be the default background color for transparent controls in the designer, leading to unreadable white-on-white labels.

Is there a way or strategy for setting the design-time background color, with similar convenience as DesignHeight/DesignWidth?


Solution

  • 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.