views:

9

answers:

0

Hi All,

As an example of what I am trying to do.

I have a DependencyObject called CompanyDivision. It has a DependencyProperty returning a FreezableCollection<Employee> called Employees. Employee is also a DependencyObject. I can then uses the WPFToolkit DataGrid.ItemsSource to bind to CompanyDivision.Employees with the AutoGenerateColumns property set to true. This displays all the Properties of Employee as columns in the DataGrid as expected.

The problem I have is that each division has a different type of Employee (where within a paritcular CompanyDivision instance the Employees collection will only have one kind of derived type) The different types of Employee each have a different set of extra dependency properties that I'd like to show up in the DataGrid. Now I can bind the properties of the derived type just fine if I explicitly add the bindings in the XAML but I'm looking for something more "just works" (for some reasonable value of just works) out of the box. I realise in the normal case with AutoGenerateColumns set to true columns and bindings are reflected from the type of the collection (Employee) but is there a dynamic runtime way of a DependencyObject letting a DataGrid know how it wants the generation of columns done so the tailoring require by the user/consumer of the DependencyObject is minimized?

I hope the scenario makes sense. Thanks