如何在 WPF 中将整数转换为颜色? 例如,我想将 16711935 转换为颜色。
如何在 Windows 窗体和 WPF 中执行如下操作?
myControl.Background = Color.FromArgb(myColorInt);
最佳答案
使用 BitConverter
将您的值转换为字节数组的类,这样您就不需要导入另一个命名空间。
byte[] bytes = BitConverter.GetBytes(16711935);
this.Background = new SolidColorBrush( Color.FromArgb(bytes[3],bytes[2],bytes[1],bytes[0]));
关于c# - 在 WPF 中将整数转换为颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21247974/