如何将RGB颜色绑定到RDLC报告?

时间:2016-01-26 09:27:04

标签: c# wpf colors rdlc rgb

这是我的方案:我正在使用.NET Framework 4和Visual Studio 2013 Ultimate开发一个WPF应用程序。

我有一个带有数据表的RDLC报告,报告的数据源是一个自定义对象。在运行时,我向我的报告发送一个自定义对象列表。

我的目标是为我的桌子的每个单元格着色,并在我的自定义对象中定义一个值,但我的颜色不能是文本值(白色,红色ecc。),它必须是RGB值(127 255 212,229 43 80 ECC)。

+----------+----------+------------+
| Column 1 | Column 2 | Column 3   |
+----------+----------+------------+
| Red      | Green    | Trasparent |
+----------+----------+------------+
| Green    | Yellow   | Purple     |
+----------+----------+------------+

你能帮我吗?

由于

2 个答案:

答案 0 :(得分:0)

试着看一下:Binding R G B properties of color in wpf

否则,您可以使用此值绑定到整数:

int RGB = (Red << 16) | (Green << 8) | Blue;

RedGreenBlue均为0-255

或者保留一个Color结构,如下所示:Color.FromRgb(Red, Green, Blue)

答案 1 :(得分:0)

此问题的解决方案是:您可以使用以下格式的字符串绑定颜色:#HEXCOLOR。

我使用这段代码来检索我的字符串:

private static string ToHex(int value)
{
   return String.Format("#{0:X}", value);
}

再见