Hi All,
Here's how my data looks. Two tables. The first has all the data in
"expanded" form, the second has just "ID" data in "pivoted" form.
Here's the "expanded" table:
DataID | RowID | ColumnID | Label | Color
---------------------------------------------
1 | 1 | 1 | Warning | Red
2 | 1 | 2 | Caution | Yellow
3 | 1 | 3 | Warning | Red
4 | 1 | 4 | Note | Green
5 | 1 | 5 | Warning | Red
....
11 | 3 | 1 | Warning | Red
....
50 | 1 | 2 | Note | Green
---------------------------------------------
Here's the "pivoted" table (the data is pivoted on "ColumnID" so that
each cell contains a DataID)
RowID | ColumnID_1 | ColumnID_2 | ColumnID_3| ColumnID_4| ColumnID_5
---------------------------------------------
1 | 1 | 2 | 3 | 4 | 5
2 | 6 | 7 | 8 | 9 | 10
3 | 11 | 12 | 13 | 14 | 15
.....
10 | 46 | 47 | 48 | 49 | 50
---------------------------------------------
Now, I want to create a GridView in XAML that looks like the "pivoted"
table but, instead of showing a DataID in each cell, it looks up the
DataID in the "expanded" table and uses the Label value instead.
Similarly, it should set the text color (Foreground) of the cell by
looking up the DataID in the "expanded" table and using the Color
value. (Note: this is a simplified example...my real situation has
even more columns that I want to use to style the cells.)
What I thought I could do was create two type converters: one that
converts from DataID (int) to Label (string), and another that
converts from the DataID (int) to Color (SolidColorBrush). Then I
could build a custom template with a TextBox/Label/TextBlock where
Text = Label and Foreground = Color.
Before I go down the road of trying to get this all to work...
* Is there an easier way (or a better way)?
* If not, do you think my idea could work?
There doesn't seem to be any built in support for pivot tables in WPF,
but I really need my data in this format.
Thanks in advance for your help!
-Dan