This must be a reasonably common scenario, but what I'm trying to do is to create a custom Editor that can dynamically populate a ComboBox with a list items in a table represented by my object's foreign key value. I could use the Category attribute to mark the Foreign Key fields and then use a Category Editor with a View Model that can deal with the dynamic data lookup, but I'm unsure how to make the CategoryEditor dynamic - for instance, in the sample, you have the Properties hard coded (below), but I won't know the PropertyName until runtime.
<propgrid:CategoryEditor.Properties> <propgrid:CategoryEditorProperty PropertyName="FontFamily" /> <propgrid:CategoryEditorProperty PropertyName="FontSize" />
<propgrid:CategoryEditorProperty PropertyName="FontStyle" />
<propgrid:CategoryEditorProperty PropertyName="FontWeight" />
<propgrid:CategoryEditorProperty PropertyName="Text" />
</propgrid:CategoryEditor.Properties>
Maybe this is totally the wrong approach - any ideas how to accomplish this? My objects are LINQ-to-SQL objects, so I'd like to be able to use the LINQ attributes (e.g., Association) to detect the Foreign Key (rather than having to code Category attributes on all of them).
Also, do you have any examples of using a PropertyGrid DataTemplate with a View Model?
[Modified at 11/11/2009 08:10 PM]
<propgrid:CategoryEditor.Properties> <propgrid:CategoryEditorProperty PropertyName="FontFamily" /> <propgrid:CategoryEditorProperty PropertyName="FontSize" />
<propgrid:CategoryEditorProperty PropertyName="FontStyle" />
<propgrid:CategoryEditorProperty PropertyName="FontWeight" />
<propgrid:CategoryEditorProperty PropertyName="Text" />
</propgrid:CategoryEditor.Properties>
Maybe this is totally the wrong approach - any ideas how to accomplish this? My objects are LINQ-to-SQL objects, so I'd like to be able to use the LINQ attributes (e.g., Association) to detect the Foreign Key (rather than having to code Category attributes on all of them).
Also, do you have any examples of using a PropertyGrid DataTemplate with a View Model?
[Modified at 11/11/2009 08:10 PM]