I need to set the listview view to a gridview that have a complex header like this (based on a 3 dimensional object list i created):
| ---------- LEVEL 0 ------------ |
| -- Level 1a -- | -- Level 1b -- |
| Lvl A | Lvl B | Lvl A | Lvl B |
EDIT: This is more ore less my object model
public class Measures
{
public string Caption { get; set; }
public List<Threshold> ThresholdList { get; set; }
}
public class Threshold
{
public string Caption { get; set; }
public double Value1 { get; set; }
public double Value2 { get; set; }
public double Value3 { get; set; }
public double Value4 { get; set; }
}
i've to bind a dynamic list of Measures
(this is my level 0), then a dynamic list of Threshold
(level 1a...) and for each threshold display values1 to 4 if they are != 0
Level 0 Is a ListView? Level 1A and level 1b are Gridviews that you want inside two different templated columns inside the level 0 List view? Then level A and level b are two more grid views inside 2 more templated columns in level 1a and level 1b?
You might be able to convert the same concept this nested GridView uses into WPF
http://forums.asp.net/t/1071521.aspx
I haven't tried it myself in wpf, but gridviews appeared to be built similarly. Just use panels instead of Divs, and less head aches with having to wory about client/serverside calls.
Also Datasets work nicer then lists.
Here is some psuedo code on how I've set up Nested Datasets before
How about something like this:
You might need to convert the Value1, Value2 properties into a collection in order to dynamically display the non-zero ones and use the same ListBox/StackPanel approach that I used to display the thresholds.
This gives the output:
And just to complete the post, here is the code I used:
Have you thought about how it should behave - your header that is?
It is easy enough to make a header that looks like the one you suggest - you could build it with some grids programatically - but that is just the header. Should you also be able to resize it like you normally can with a listview header?
Maybe you looking for something like a TreeListView?
http://www.codeproject.com/KB/WPF/TreeListView.aspx
I think that is what I would go after to display multidimentional data - it is easy to understand and use, where a custom listview can be hard to implement to behave right.