Change custom color for Rectangle.Fill or Grid.Background

后端 未结 2 1180
耶瑟儿~
耶瑟儿~ 2021-01-22 04:32

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 f

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-22 04:39

    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);
    

    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.

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

提交回复
热议问题