[WPF] Random Brush

C#/WPF 2020. 10. 12. 18:46
728x90
/// <summary>
/// Random Color
/// </summary>
/// <returns></returns>
private Brush RandomBrush()
{
    Brush result = Brushes.Transparent;

    Random random = new Random();

    Type brushesType = typeof(Brushes);

    PropertyInfo[] properties = brushesType.GetProperties();

    int randomValue = random.Next(properties.Length);
    result = (Brush)properties[randomValue].GetValue(null, null);

    return result;
}

 

728x90
Posted by kjun.kr
,