i replace the ContentPresenter in the DataGridCell‘s Template with a TextBlock an now i search for the correct Binding to the content.
The normal way is Text="{TemplateBinding Content} for the TextBlock – it doesn’t work. Also Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Content, Mode=TwoWay}" doesn’t work correct.
Any other ideas?
Suppose you have changed the
DataGridCell Templateto the followingSince you removed the
ContentPresenter, theDataGridCellhas no way of displaying itsContent. It’s still there though. TheDataGridCell.Contentis a
TextBlockcontaining your originalTextand theTextBlockin theTemplateis another.So you’ll get the correct
Textby binding it to theContent.Textproperty of theTemplatedParentSo, to sum it up. This works