Dynamic loading of user control in datagrid second column on first column's combo box selection change

Apr 13, 2009 at 12:14 AM
Edited Apr 13, 2009 at 2:42 PM

Hi,

I am using datagrid, which has one combo box in it's first column. The combo box is populated with different categories and each category is having multiple attributes, and these attributes set is different for each category. Hence I have to populate different controls for those attributes in the second column on category selection at run time e.g. if an attribute is string value then i will show textbox and if it is boolean type then checkbox. Further these controls will be visible only in Add/Edit mode, and in view mode the column will have plain text i.e. textblock. 

I am thinking to embed a panel control in the second column and when user selects/changes any category, a usercontrol will be loaded in the panel. This usercontrol will have one property with name CategoryID which will decide which controls are to be populated in usercontrol. These all things will be done at run time. Hence, I don't have enough knowledge to load a usercontrol at runtime in wpf.

My second problem is to detect/find the embedded grid controls at runtime (in my case panel). Unless until I don't find the panel control; I can't load user control in that. So please guide me. I will be thankful if someone helps me ASAP. I will appreciate your help. Thank you in advance. 

Thanks and regards, 

Pravin