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屋!