Using PropertyGridValueTemplateSelector

Grids for WPF Forum

Posted 6 years ago by Darcy Davidson
Version: 17.2.0665
Avatar

Hi,

I am attempting to use the TreeListView control adjacent to a PropertyGrid to display multiselected/collection data in a 'flattened' format.  To this end, I've reused my TypeDescriptorFactory and PropertyModel classes to organize my objects in the way I want, and I have dynamically created TreeListView columns with ContentControls datacontext'ed to IPropertyModels.  I am stuck on how to get my ContentControl to select and use the same editor that would be used in the adjacent property grid.  When I snoop the property grid, I see it is using the PropertyGridValueTemplateSelector.  I can't quite understand its usage based on the documentation, and can find no example.

Any help to move me forward on this would be much appreciated.

Thanks,

D'Arcy

Comments (3)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

PropertyGridValueTemplateSelector is a DataTemplateSelector that requires the item to be an IPropertyModel and it returns the appropriate value-editing template for that model.  That being said, it generally has to walk up the property model tree to get the PropertyGrid that created the model and use info from that to make a DataTemplate selection.  The logic used is "Property Editors" documentation topic.

PropertyGrid is itself a TreeListView.  We effectively set the PropertyGridValueTemplateSelector instance to the TreeListViewColumn.CellTemplateSelector for the value column.


Actipro Software Support

Posted 6 years ago by Darcy Davidson
Avatar

Thanks,

That pretty much matches my understanding.  I cant figure out why PropertyGridValueTemplateSelector.SelectTemplate(IPropertyModel, gridInstance) returns nothing.  I can't see any meaningful difference between my IPropertyModel (produced manually), and the one created by the PropertyGrid.

Regards,

D'Arcy

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

We use an internal class as the root of the data model tree, and that class has a pointer to the PropertyGrid.  If you are manually constructing your data model tree, then the PropertyGridValueTemplateSelector wouldn't be able to find the owner PropertyGrid and then couldn't do most of its logic.  Maybe that's what's going on here.

You'd probably have to make your own custom template selector class.  If you'd like our PropertyGridValueTemplateSelector source code to use as a guide for our logic, please write our support address and we can send it to you.  But you'd have to alter it to somehow point it to a PropertyGrid internally.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.