Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
500
WPF - XAMGrid - How to build hierarchical grid in code behind with dynamically created columns known at runtime
posted

We need to build a hierarchical grid in code behind with dynamically created columns, which are known at runtime. We built an application, where the user can select everything he wants to see in the report. He can select products and productgroups, targetgroups (e.g. Men) and facts (e.g. Buyers abs). I prepared a screenshot for you with an example.

The samples for "Self-Referencing Data" or "Hierarchical Financial Data" would be exactly what we need.But in these samples and all other code snippets I found up to know I only saw code based on a list of objects of a certain class with fixed properties. For example there is a class "Employee"  with properties "Id", "Name" and "JobTitle". These properties are connected to columns in the grid using the property name as the key. And this is the main problem for us because we have to generate the grid in code behind, after the user has selected what he wants to see. At that point we know which columns and rows we need to generate in the grid.

It was no problem to generate a DataView dynamically with all columns and rows I need, but the grid shows this input as a "flat" table without hierarchies. I don't know how I could implement something like the sample code, using a IList and connecting it to a special columns, which the grid uses to identify parent objects which have child objects?

Does anybody has an idea how I could realize hierarchies not based on objects of a class with fixed properties?

Thanks C.