WPF中仅设计时的背景色? [英] Design-time-only background color in WPF?
问题描述
在WPF XAML中,方便的 DesignHeight
和 DesignWidth
例如在代码中
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.
但是,我经常构建深色的UI,其中的标签等必须为白色,但是我的控件仍然需要透明的背景色。这会造成设计时的不便,因为白色似乎是设计器中透明控件的默认背景色,导致白色标签无法读取。
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.
一种设置设计时背景色的方法或策略,与DesignHeight / DesignWidth类似?
Is there a way or strategy for setting the design-time background color, with similar convenience as DesignHeight/DesignWidth?
推荐答案
此处: XAML编辑器的黑色背景。有很多选择,包括在运行时检查 System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)
。
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.
这篇关于WPF中仅设计时的背景色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!