WPF Datagrid create new dependent object when entering values
===

I have a Datagrid in WPF bound to a list of objects, which in turn have more objects depending ("hanging") on them. When I create a new row the "Parent" object gets created OK, but the "Child" is not.

The parent can have only one child (not a collection), I tried to create a new child in the parent's default constructor, but then the Datagrid is not populated correctly.

To put it short (and also in English) I would like to display in the grid:

Col1: Parent.Property1

Col2: Parent.Propert2

Col3: Child.Property1

(all of them in the same row)

If the child already exists it gets displayed OK, and I can also edit/save without issues (using EF 4.3.1 Code First, everything fine there). The problem comes when I try to create the child automatically within the Datagrid.

XAML snippet

This is a sample column for the Parent object

    <DataGridTextColumn x:Name="refrentadoColumn" Binding="{Binding Path=Refrentado}" Header="Refrentado" Width="SizeToHeader" />
This is a column for the "Child" (Resistencia) object

    <DataGridTextColumn x:Name="resistenciaEdad" Binding="{Binding Path=Resistencia.Edad, Mode=TwoWay}" Header="Edad" Width="SizeToHeader" />

The parent object has a property "Resistencia" pointing to a Resistencia object.

It is important for the user experience that the fields of both the parent and child are displayed in the same row, and I cannot have the child properties become part of the parent object (that would mean: no child) because I use the child object for other purposes.

I'm trying to avoid code behind as much as possible (MVVM)... It would be OK to always create a child when a parent is instanciated, but as I told, if I try to create it in the default constructor then the existing childs are not displayed in the Datagrid.

Thank you all for your time and interest!