DataTemplate for objects

Grids for WPF Forum

Posted 6 years ago by Erel Uziel
Version: 17.2.0661
Avatar

I'm using a custom data factory.

I have an object with other objects as child members.

Currently ValueAsString is called for each of the IPropertyModel and it they are treated as strings instead of objects.

With the previous PropertyGrid and probably with a slightly different configuration, the data factory method was recursively for each of the objects:

protected override IList<IPropertyDataAccessor> GetProperties(object value, DataFactoryOptions options)

 

Should I explicitly set the DataTemplate?

Comments (1)

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

Hi Erel,

The data factory's GetPropertyModels method will still be called to ask for child properties of a given data object.  And that should generally work recursively.

As for the DataTemplate that gets set for the property editor, the PropertyGridValueTemplateSelector class is what has all the logic for picking a DataTemplate.  The default fallback is to just use a TextBox and bind to ValueAsString.  That's probably what you see.  To change that you can use multiple properties on IPropertyModel, or you can also define property editors.  There is some extensive documentation on this in the "Property Editors" documentation topic you can read through.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.