DisplayMemberBinding and DataTemplates in TreeListViewColumn

Grids for WPF Forum

Posted 7 months ago by Stefan Angerer
Version: 24.1.2
Platform: .NET 6.0
Environment: Windows 11 (64-bit)
Avatar

Hi,

I try to use the DisplayMemberBinding property from TreeListViewColumn.

If I do this the DataContext and Content for the ContentPresenter of the Cell suddendly is a PixelSnapper (From Actipro Namespace)

The Border (Child of TreeListViewItemCell, Parent of the ContenPresenter) has the expected DataContext.

So if I use the DisplayMemberBinding I can't use DataTemplates anymore. I wan't to do a combination to enable dynamic columns.

Regards Stefan

Comments (1)

Posted 7 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If you use DisplayMemberBinding, it will create a TextBlock with the DataContext being set to your expected DataContext, and the TextBlock.Text property being bound using the DisplayMemberBinding.  In that case, a PixelSnapper also wraps the TextBlock to ensure an even height.  That PixelSnapper is used as the cell's Content.

When not using DisplayMemberBinding, the DataContext is used as the cell's Content and cell templates will be available.

That is by design.  If you want to use DataTemplates, you'd have to not use DisplayMemberBinding.


Actipro Software Support

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