I have a pretty simple CRUD app which displays data from a database in a datagrid. This works fine. I'd like to have a comment column in the datagrid, where each row has a textbox that the user can insert a comment into. The problem is, the property in the class displaying data doesn't get updated with the comment. I can use a simple DataGridTextColumn with IsReadonly="False" for that column. This actually gets the comments, but it look horrible, and the user has to double-click the cell to enter it. With a textbox, validation looks smoother and the user only has to click once to enter it, but here the binding doesn't work. I've tried different variantions of DataGridTemplateColumn but I can't seem to get it right or find a working example. What am I missing?
<DataGridTemplateColumn Header="Comment" Width="120" IsReadOnly="False">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=UserComment}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox IsEnabled="true" Text="{Binding Path=UserComment}"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>