UITypeEditor.PaintValue not being respected

Topics: Building and extending application blocks
Mar 31, 2011 at 8:07 PM

I am trying to customize the way certain configuration objects are edited using the EntLib configuration tool.  I've created a custom type editor using UITypeEditor and overridden the PaintValue method, but the configuration tool continues to display the value as an edit box with an elipsis button (it's a modal editor).

How can I draw my own control next to the elipsis button?  I don't want the value to be rendered as a string in an edit box.  I've poured through the source code and for the life of me, I can't find where the decision to use an edit box here is being made.  Any help would be greatly appreciated.


Apr 1, 2011 at 6:53 AM

I'm not sure if this is possible as I haven't explored this aspect of a UITypeEditor yet.  However, since this is not really specific to Enterprise Library, it might also be worth to post this question in other .NET forums and checking out the documentations in MSDN about this topic such as this one.


Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.

Apr 1, 2011 at 1:07 PM

It works in other hosts.  My Paint method is called as expected.

It does not work in the Configuration Utility host.

Apr 1, 2011 at 3:06 PM

I figured it out.

Apparently, using a UITypeEditor derivative in your EditorAttribute on a configuration property limits you to the TextBox/Button layout and, as I've seen, ignores the Paint() method.

You can, however, specify a type that isn't a UITypeEditor at all.  You can name an arbitrary custom WPF control as the editor, and the configuration tool will render your control inline.  To interact with the value of the property that your custom WPF editor is supposed to be editing, you can cast the control's DataContext as a BindableProperty and interact with its Value.

You can also use WPF's binding infrastructure to bind the EntLib binding property to a subordinate control, like a TextBox or a Label.

This is how some of the stock editors work, like the MultilineTextEditor.  I guess I just assumed that Editors had to be UITypeEditors, but as it turns out, they don't.

Hope this helps others.