【发布时间】:2018-04-27 17:09:23
【问题描述】:
我想更改随机按钮。 但问题是我想用随机数的变化颜色来做到这一点。
现在我正在像这样改变它,但我想动态改变改变颜色的数量。
private void ChangeColor()
{
Random rand = new Random();
Color[] colors = new Color[]
{
Colors.Red,
Colors.Blue,
Colors.Green,
};
But0_1.Background = new SolidColorBrush(colors[rand.Next(0, 3)]);
But0_1.Background = new SolidColorBrush(colors[rand.Next(0, 3)]);
But0_2.Background = new SolidColorBrush(colors[rand.Next(0, 3)]);
But0_3.Background = new SolidColorBrush(colors[rand.Next(0, 3)]);
But0_4.Background = new SolidColorBrush(colors[rand.Next(0, 3)]);
But0_5.Background = new SolidColorBrush(colors[rand.Next(0, 3)]);
But0_6.Background = new SolidColorBrush(colors[rand.Next(0, 3)]);
But0_7.Background = new SolidColorBrush(colors[rand.Next(0, 3)]);
}
【问题讨论】:
-
您能否更详细地解释您的要求?
-
您可以通过选择随机的红绿蓝值来创建随机颜色。