Add extra column to propertygrid

Grids for WPF Forum

Posted 11 years ago by Moondance
Version: 12.2.0573
Avatar

Is there a way to have the propertygrid dislay 3 columns instead of the two default ones (property name and property value) and associate as different editor in the third column?

Thanks

Comments (6)

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

Hi,

We haven't really tried that so I can't say whether it's possible or not (without some possible visual artifacts).  But you might be able to inherit PropertyGrid and add another entry to its Columns collection.  Our value column is added to it like this:

TreeListViewColumn valueColumn = new TreeListViewColumn() {
	Header = "Value", MinWidth = 25, IsResizable = false
};
BindingOperations.SetBinding(valueColumn, TreeListViewColumn.CellContainerStyleProperty,
	new Binding("ValueCellContainerStyle") { Source = this });
BindingOperations.SetBinding(valueColumn, TreeListViewColumn.CellTemplateSelectorProperty,
	new Binding("ValueTemplateSelector") { Source = this });
columns.Add(valueColumn);

You could probably do something similar.


Actipro Software Support

Posted 11 years ago by Mike Ausen
Avatar

I have added the third column but do not know how to get the correct data to appear there. I can get the same data as column 1 or 2 to appear but not the data intended for column 3. Snoop shows the DataContext is set in columns 1 and 2 but not in column 3.

 

Adrian provide the solution.

 

Another issue is the column resize.

When you drag the line between the second and third columns, the third column does not change size and the first and second columns do change size. 

Any suggestions?

[Modified 11 years ago]

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

Hi Mike,

Could you make a new simple sample project showing the issues you are having and send that over?  Then we can use it to debug with.  Please reference this post and rename the .zip file extension so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 11 years ago by Mike Ausen
Avatar

Hi,

I just sent a email containing the small demo program.

Mike Ausen

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

Hi Mike,

Thank you for the sample. The resize issue was definitely a bug, which we've fixed for the next maintenance release. The only work around for the interim would be to include the following style:

<local:PropertyGridDynamicColumn ...>
	<local:PropertyGridDynamicColumn.SplitterStyle>
		<Style TargetType="propgrid:TreeListViewSplitter">
			<Setter Property="Grid.Column" Value="{Binding (propgrid:TreeListViewRowPresenter.Column), RelativeSource={RelativeSource Self}}" />
		</Style>
	</local:PropertyGridDynamicColumn.SplitterStyle>
	...
</local:PropertyGridDynamicColumn>

Your sample doesn't actually have the DynamicCellContainerStyle or DynamicTemplateSelector properties that your new column is suppose to bind to, so it's hard to say what the issue is there. Keep in mind that both the cells created for the default name and value columns get the same Content as your new column.

But the styles for these cells choose to ignore the Content and bind to properties on the parent IPropertyDataAccessor (which ends up being a PropertyGridDataAccessorItem). You can see how we do this in the default styles if you search for ValueCellContainerStyleKey (the default Style applied to value cells) and DynamicValueTemplateKey (the default DataTemplate used in value cells).


Actipro Software Support

Posted 11 years ago by Mike Ausen
Avatar

The workaround fixed the problem in the production code and the demo program.

In the demo program included only the code required to show the problem. So, yes, I intentionally left out the things you mentioned.

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.