0

I am trying to present a table of data where every item in the table has a common set of properties but groups of items have properties that are common to just that group.

So for example I might have the objects

  Binoculars    Item              Price  Aperture  Magnification  
                10x50 binoculars  £30    50        10
                15x70 binoculars  £79    70        15
  Telescopes    Item              Price  Aperture  Mount  
                90mm refractor    £119   90        AltAz
                90mm refractor    £149   90        Equatorial
  Mounts        Item              Price  Mount  
                AZ1               £79    AltAz
                EQ3               £179   Equatorial
                EQ5               £279   Equatorial

At the moment the common properties are held in fields in a database copied to an internal BindingList structure. The custom fields are held in an XML description within a field in that table.

The question is ... is there any suitable structure in c# / silverlight that would allow me to represent this in a single table.

Jarvis Brand
  • 1
  • 1
  • 3
  • Could you not just have 6 columns (Product Name, Item, Price, Aperture, Mount and Magnification) and where the item doesn't have a value for that column just have n/a? – sr28 Mar 19 '15 at 14:07
  • If you're talking about Silverlight or WPF you can just have a custom usercontrol for each item type. Add a StackPanel to your form and add each control to the stack panel, so it ends up looking like a grid. I've done this before in the past and it works. – Jon Mar 19 '15 at 14:10
  • I can't do it with 6 columns and mark some n/a. The example above is just that, an example. In use I do not know what the extra columns will be or how many columns there will be because they are user defined properties. Equally I don't know how many item types there will be so I can not define a custom user control for those types. The definition of the custom control itself would need to be dynamic (is that possible?) I would imagine that what I need is some control element where I can implement the rendering of the control myself. – Jarvis Brand Mar 19 '15 at 15:09

1 Answers1

0

You can use ItemsControl for each of the datagridview. To generate a particular datagridview you can refer to the following link for your reference: How do I bind a WPF DataGrid to a variable number of columns? The answer by Fredrik Hedblad gives the appropriate solution to your question as to how you can bind the number of columns and the corresponding column behavior during runtime.

Community
  • 1
  • 1
Sormita Chakraborty
  • 1,015
  • 2
  • 19
  • 36