简体   繁体   English

Windows Phone 8阵列设置Color.FromArgb

[英]Windows phone 8 array to set Color.FromArgb

I would like to set the background colour of the grid using the colours array. 我想使用colors数组设置网格的背景颜色。

int[] coloursArray = {255, 0, 100, 0};    
GridBackgroundDARK.Background = new SolidColorBrush(Color.FromArgb(coloursArray.All));

The error is: 错误是:

No overload for method 'FromArgb' takes 1 arguments 方法'FromArgb'没有重载需要1个参数

Thank you in advance for any help :) 预先感谢您的任何帮助 :)

I don't think All is what you're looking for here. 我不认为All都是你在这里寻找的。 If you want to use the values in the array, assuming they're in the correct order, you can do this: 如果要使用数组中的值,假设它们的顺序正确,则可以执行以下操作:

Color.FromArgb(coloursArray[0], coloursArray[1], coloursArray[2], coloursArray[3])

If you're going to do it often, you could create a method that does it for you 如果你经常这样做,你可以创建一个为你做的方法

public Color ColourFromArray(int[] cArray) 
{
    //add your error handling checks
    //...

    return Color.FromArgb(cArray[0], cArray[1], cArray[2], cArray[3])
}

你需要提供所有4个参数a,r,g,b。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Color.FromArgb(...); 安全信息 - Color.FromArgb(…); security message 无法使用 Color.FromArgb 设置透明度(但 Color.Transparent 有效) - Unable to set transparency using Color.FromArgb (but Color.Transparent works) 如何使用 Int Array To Color.fromargb 并创建新图像 c# - How To Use Int Array To Color.fromargb And Create A New Image c# Color.FromArgb如何将Int32作为参数? - How can Color.FromArgb take Int32 as parameter? 不能在 DataGridView 单元格 BackColor 中使用 Color.FromArgb - Cannot use Color.FromArgb in DataGridView cell BackColor Color.FromArgb(Int32,Int32,Int32)超出范围 - Out of range in Color.FromArgb(Int32,Int32,Int32) 给定一个可以为空的int时返回Color.FromArgb的最佳实践C# - Best practices for returning a Color.FromArgb when given an int that may be null C# C#无模式对话框:如何从无模式对话框返回3个不同的值到主窗体,并将它们放在一起用作Color.FromARGB? - C# Modeless Dialog: How to return 3 different values from modeless dialog to main form and put them together to use as Color.FromARGB? 在Windows Phone的应用程序中以编程方式设置电话颜色主题 - Set phone color themes programmatically within app in Windows Phone 在Windows Phone中从一组颜色中为文本框设置随机颜色? - set random color to a textbox from a set of colors in windows phone?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM