C# 如何从 RGB 代码中获取画笔?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16240581/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 00:29:42  来源:igfitidea点击:

How to get a Brush from a RGB Code?

c#windows-runtime

提问by gurehbgui

How can I get a Brushto set a Background of e.g. a Gridfrom a RGB Code.

我怎样才能从 RGB 代码中Brush设置一个背景,例如 a Grid

I hace the RGB Code as a int:

我将 RGB 代码设为int

R = 12
B = 0
G = 255

I need to know how to convert it into a Brush

我需要知道如何将其转换为 Brush

采纳答案by Chris Sinclair

var brush = new SolidColorBrush(Color.FromArgb(255, (byte)R, (byte)G, (byte)B));
myGrid.Background = brush;