wpf 如何在 vs2012 中更改 XAML 设计器的背景颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14272205/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change background color of XAML designer in vs2012?
提问by Ted Corleone
I just try to view the result after XAML code in Designer. However, it's hard to recognize the black letters when I use a dark theme in vs2012.
我只是尝试在 Designer 中查看 XAML 代码后的结果。但是,当我在 vs2012 中使用深色主题时,很难识别黑色字母。
My question is how to change designer background to white color without modifying the dark theme. Seems to change several options in tools?
我的问题是如何在不修改深色主题的情况下将设计器背景更改为白色。似乎改变了工具中的几个选项?
Thanks
谢谢
Please skim over all the answers. All have different approaches and it may be that the later ones will suit your needs better.
请浏览所有答案。所有人都有不同的方法,可能后者更适合您的需求。
回答by VisualStudioEspresso
In VS 2013 you can change XAML designer background. Go to:
在 VS 2013 中,您可以更改 XAML 设计器背景。去:
Tools -> Options -> Environment -> Fonts and Colors
In the combobox at the top of the panel, select:
在面板顶部的组合框中,选择:
Show settings for: XAML UI Designer
Then set:
然后设置:
Item foreground : white
Item background : white or very light grey (custom)
回答by MechEthan
Alternate approach that doesn't involve code:
不涉及代码的替代方法:
Install the "Visual Studio Color Theme Editor" Extension
Create a new custom theme based on the one you want to modify. (2013-specific help image below)
Click the "Show All Elements" filter button in the upper-left of the theme editor
Type "artboard" in the search-box in the upper-right of the theme editor
Set the "
Cider -> ArtboardBackground
" color to a different color of your choice.- VS2013 also introduces a second value "
Cider -> ArtboardSecondaryBackground
" to create a helpful checker-boarding effect.
- VS2013 also introduces a second value "
- Yay! :D
安装“ Visual Studio 颜色主题编辑器”扩展
根据您要修改的主题创建一个新的自定义主题。(下面是 2013 特定的帮助图片)
单击主题编辑器左上角的“显示所有元素”过滤器按钮
在主题编辑器右上角的搜索框中输入“artboard”
将“
Cider -> ArtboardBackground
”颜色设置为您选择的其他颜色。- VS2013 还引入了第二个值“
Cider -> ArtboardSecondaryBackground
”来创建有用的棋盘格效果。
- VS2013 还引入了第二个值“
- 好极了!:D
Note:The "Cider -> ArtboardBackground
" color theme field is found in VS2012 but I cannot confirm whether it has the same name in VS2010.
注意:Cider -> ArtboardBackground
在VS2012中找到了“”颜色主题字段,但我无法确认它在VS2010中是否具有相同的名称。
Edits:Added link to VS2013 (thank you @treaschf for the note!) official extension, although I think its an "RC" version. Also, added handy pictures.
编辑:添加了到 VS2013 的链接(感谢@treaschf 的注释!)官方扩展,尽管我认为它是一个“RC”版本。此外,添加了方便的图片。
回答by Antony Scott
I've had the same problem and came across a very useful blog post which details how to use a trigger for a style in the App.xaml
我遇到了同样的问题,并遇到了一篇非常有用的博客文章,其中详细介绍了如何在 App.xaml 中为样式使用触发器
<Style TargetType="{x:Type UserControl}">
<Style.Triggers>
<Trigger Property="ComponentModel:DesignerProperties.IsInDesignMode"
Value="true">
<Setter Property="Background"
Value="White" />
</Trigger>
</Style.Triggers>
</Style>
http://caraulean.com/2012/visual-studio-2012-dark-theme-tip/
http://caraulean.com/2012/visual-studio-2012-dark-theme-tip/
回答by Hyman Ukleja
As of Visual Studio 2017 the XAML designer has a "Toggle artboard background" button, which has the effect of changing the transparent from a black checkerboard to a white checkerboard.
从 Visual Studio 2017 开始,XAML 设计器有一个“切换画板背景”按钮,它具有将透明从黑色棋盘格更改为白色棋盘格的效果。
The benefit of this is there is no need to modify your XAML files.
这样做的好处是无需修改 XAML 文件。