更改 Rectangle.Fill 或 Grid.Background 的自定义颜色 [英] Change custom color for Rectangle.Fill or Grid.Background

查看:30
本文介绍了更改 Rectangle.Fill 或 Grid.Background 的自定义颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下内容更改自定义颜色矩形:xaml 中的#A125AA".

i can change custom color Rectangle with something like : "#A125AA" in xaml.

但我不知道在哪里可以找到代码更改自定义颜色

But i don't know where to find code change custom color i have

我只知道区域颜色的代码

i just know code for color arealy have

this.gridgcolor.Background = new SolidColorBrush(Colors.Blue);

推荐答案

可以通过RGB设置颜色.这不像您在 xaml 中那样以十六进制完成.

you can set the color through RGB. This isn't done in hex like you're doing in your xaml.

Color color = new Color() { R = 255, G = 255, B = 255 };
Brush brush= new SolidColorBrush(color);

您在示例中的十六进制值 #A125AA 也是 RGBR = A1,G = 25,B = AA

the hex values you have in your example #A125AA are also RGB R = A1, G = 25, B = AA

您可以使用辅助方法来转换这些值这样您就可以将它们添加到您的颜色对象中.

You could convert these values with a helper method so you can add them to your Color object.

如果要使用名称,这里 也是一大堆与其名字相匹配的 RGB 代码列表

If you want to use the names, here is also a list of a lot of RGB codes matched to their names

这篇关于更改 Rectangle.Fill 或 Grid.Background 的自定义颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆