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 Template
to the followingSince you removed the
ContentPresenter
, theDataGridCell
has no way of displaying itsContent
. It's still there though. TheDataGridCell.Content
is aTextBlock
containing your originalText
and theTextBlock
in theTemplate
is another.So you'll get the correct
Text
by binding it to theContent.Text
property of theTemplatedParent
So, to sum it up. This works
The data context of the data grid cell should be the data itself. So the binding should simply be: