Custom property editor

Grids for WPF Forum

Posted 10 years ago by wpf.acp
Version: 9.1.0503
Avatar
I am trying to devise a way to have a nice right aligned button for each and every editor in a property grid. The button is supposed to be visible for all nullable and collapsed for all non-nullable properties. Click on a button should raise a Reset command for an accompanying property (probably similar to existing editors for nullable types).

Is there an "easy" way to achieve anything remotely similar to this? If there is no solution to cover all editors, I would be more than happy to accomplish the desired effect for a single editor and then reproduce for each particular editor I might need.

Is there any guide on creating editors based on existing ones. I have tried several things but I failed miserably. I have searched the forum and the sample app for clues but could find none. Please advise.

Comments (3)

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

The Property Editors QuickStart shows how a button can be added to the right side of a TextBox and used as a property editor. Then you could selectively hide the button if the ValueType is not a class, using a custom IValueConverter. You can also reuse the PropertyGrid.ResetValue command to actually reset the value.

If you would like to add the "reset" button while retaining the existing property editors, then you'd probably have to build a custom Style for the value cells. Using the default Styles from the PropertyGrid, you could take the default "ValueCellContainerStyle" Style and add the button there. Then you'd use your Style for the value cells by calling:
this.propgrid.Columns[1].CellContainerStyle = <your Style>;
Alternatively, you could add a third column to the PropertyGrid via the Columns property. We don't currently have a sample of this or documentation, as it's on our TODO list.


Actipro Software Support

Posted 10 years ago by wpf.acp
Avatar
Can you please tell me where to find "ValueCellContainerStyle" or simply paste it here?

I have managed to create my own style that to some degree worked as I wanted it to work. The big problem I had was loss of TypeConverter functionality. It would be great if I could build upon the default style already used by the PropertyGrid.

As for adding a third column, I have found a problem with this approach and thus started a new forum thread.

Can you please help? Thanks!
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
If you are an existing WPF Studio customer, you can download the default Styles (which includes "ValueCellContainerStyle") from our site. Please see this blog post for more information.

Otherwise, you can email our support email and request the default Styles.

If you already have the default Styles, then ValueCellContainerStyle is located in the Themes\PropertyGrid\Common.xaml file under the PropertyGrid folder.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.