Property Item style

Grids for WPF Forum

Posted 13 years ago by Steve
Version: 11.1.0542
Hi, I've created a collection of dynamic properties and some of the properties are marked with specific attributes. Based on the attributes I would like to style the property name so the user can distinguish between different property types -to make it clearer to the user. I can change the background colour (based on one of your other forum posts) but how would I do it so I can add an Icon next to the display name or better still include the icon left of the actual editor.

There is no Content element on the PropertyGridDataAccessorItem as it inherits from TreeListViewItem. Is there anyway that I can change the Template for a TreeListViewItem where by I can insert a ‘type icon’ based on the property attribute

“Property Name” “Property Type Icon” “Property Editor”

If I wanted to build the template in code then I guess I could do it with a binding similar to the xaml below but I'm not sure how to build the template so I get the DisplayName, an Icon amd then the Editor .. am I going down the wrong path here?

  <Style TargetType="{x:Type propgrid:PropertyGridDataAccessorItem}">

         <Trigger Property="DataAccessorType" Value="Property">
            <Setter Property="Template" Value="{Binding DataContext, RelativeSource={RelativeSource Self}, Converter={StaticResource PropertyTypeToBooleanConverter}}" />

Thanks for any help you can give.

Comments (2)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Steve,

The WinForms PropertyGrid Functionality demo shows one way to add an icon to the name cells. You can customize the name cells in the same manner as with the value cells, using one or more PropertyEditor's which are mapped to one or more properties (by name, type, or both). In the name cell case though, you'd set the NameTemplate* properties on PropertyEditor, instead of the ValueTemplate* properties.

The WinForms PropertyGrid Functionality demo effectively redefines the default property editor/data template used for the name cells. But another way would be to define a PropertyEditor per property type (or name) that uses a DataTemplate with a fixed icon and a TextBlock bound to the DisplayName of the associated property (much like seen in the demo).

Actipro Software Support

Posted 13 years ago by Steve

many thanks for quick response, I'm impressed. Also thanks to you pointing me in the right direction as I've managed to get it sorted.

Great stuff!


The latest build of this product (v24.1.2) 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.