views:

326

answers:

2

I'm still experimenting with DynamicObjects. Now I need some information: I'm trying to bind an object inheriting from DynamicObject to a WPF DataGrid (not Silverlight).

How do I get the DataGrid to automatically create its columns from the available public properties of the object that are typically generated at runtime? Is that possible actually?

A: 

I hope that this answer help You :

How to update or refresh a DataGrid dynamically in SilverLight ?

a. List which is to be bind must be ObservableCollection

b. Item of list of business class must implement INotifyPropertyChanged interface.

I find it here ;)

netmajor
Not really but thanks anyway. I'm talking about DynamicObjects and C# 4.0 which means that somehow DataGrid has to get to know what public properties this dynamic object offers. I have already tried to implement my own DataGrid by inheriting from Selector and constructing a UniformGrid from the information provided to the OnItemSourceChanged method. But I can't get the dynamic properties of the object by using GetProperties. So I need to find another way to get this information.
SeveQ
A: 

I think the DataGrid uses TypeDescriptor to get the object properties to create the columns. So you should be able to achieve this if your DynamicObject implements ICustomTypeDescriptor. Implement the GetProperties method so that it returns the dynamic properties of your object.

Thomas Levesque