Visual Studio扩展中的颜色

编程入门 行业动态 更新时间:2024-10-21 03:36:18
本文介绍了Visual Studio扩展中的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发VS扩展,我想实现我的UI根据所选择的VS-color-scheme使用颜色(字体,背景等).做这个的最好方式是什么.我可以在WPF中绑定某些静态资源吗?

I'm developing a VS extension and I want to achieve that my UI will use colors (font, background etc.) depending on the selected VS-color-scheme. What is the best way to do this. Can I bind against some static ressources in my WPF?

推荐答案

是的,绑定到静态VS资源是最好的方法. VS 2012+支持该功能,如下所示:

Yes, binding to static VS resources is the best approach. It is supported in VS 2012+ and looks like this:

<ResourceDictionary xmlns="schemas.microsoft/winfx/2006/xaml/presentation" xmlns:x="schemas.microsoft/winfx/2006/xaml" xmlns:vs_shell="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.11.0"> <Style TargetType="Label"> <Setter Property="Foreground" Value="{DynamicResource {x:Static vs_shell:EnvironmentColors.ToolWindowTextBrushKey}}"/> </Style> <Style TargetType="TextBox"> <Setter Property="Foreground" Value="{DynamicResource {x:Static vs_shell:EnvironmentColors.ToolWindowTextBrushKey}}"/> <Setter Property="Background" Value="{DynamicResource {x:Static vs_shell:EnvironmentColors.ToolWindowBackgroundBrushKey}}"/> </Style> </ResourceDictionary>

请参见 EnvironmentColors类颜色.

更多推荐

Visual Studio扩展中的颜色

本文发布于:2023-11-13 14:37:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584598.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:颜色   Visual   Studio

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!