Type Converter not working

Grids for WPF Forum

Posted 15 years ago by Mike Benson
I put a type converter attribute on a property in my class and it is not be created / called.

If I go into the sample project and comment out this code

      <propgrid:PropertyEditor ValueTemplateKey="{x:Static propgrid:BuiltinEditors.DynamicStringValueTemplateKey}" />
in file [your path here]\Actipro Software\WPFStudio\v4.5.0484\SampleBrowser\ProductSamples\PropertyGridSamples\QuickStart\CustomTypeConverters\MainControl.xaml

lines 55-58 I can reproduce the behaviour. Basically, I have a plugin framework and users dont have a way to modify my xaml so I need the TypeConverter attribute to work without having to modify my xaml and tell it that the TypeConverter is there.

Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Mike,

You need to include the code you removed from the sample, as it states in the comment above it.

By default the PropertyGrid binds the value editors (e.g. TextBox, ComboBox, etc) directly the to property's value. Because of the abstraction layer needed, this binding has no way of knowing a TypeConverterAttribute was present on the property. Since the value editors are actually bound to a data accessor which wraps the object/property, and not directly to the object/property. It is able to see and use TypeConverterAttributes defined on the type definitions, since the type it not affected by our abstraction layer.

In order to support TypeConverterAttributes defined on the properties, we include a ValueAsString property in our abstraction layer (in addition to the Value property). When you use the ValueAsString property, we can then leverage TypeConverters defined on the property.

The code you removed above changes the "default" value editor to one that uses the ValueAsString property (opposed to the Value property).

Hope this helps.

Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.