title: Binding datagrid WPF to two different classes with lists?
body: <p>Of course I have searched everywhere on the web but I can't find the solution of my problem.</p>
  
  <p><strong>My problem</strong></p>
  
  <p>I have Patient Class that contains a list of Audiograms (Audiogramm Class).
  Actually, I can display list of Patients in the DataGrid. But I want to display, for each patient, his Audiogram in a DataGrid (WPF).</p>
  
  <pre><code>class Patient
  {
      public Patient(string patientid, string genre, string createdate)
      {
          this.patientID = patientid;
          this.genre = genre;
          this.createDate = createdate;
          audiogram = new List&amp;lt;Audiogram&amp;gt;();
      }
  
      public string patientID { get; set; }
      public string genre{ get; set; }       
      public string createDate { get; set; }
  
      public List&amp;lt;Audiogram&amp;gt; audiogram { get; set; }
  }
  
  class Audiogram
  {
      public Audiogram(string typeData, string actionDate)
      {
          this.typeData = typeData;
          this.actionData = actionData;
      }
  
      public string typeData { get; set; }
      public string actionData { get; set; }
  }
  
  XmlNodeList nodeList = root.SelectNodes("/pt:NOAH_Patients_Export/pt:Patient/pt:Patient", nsmgr);
  
  foreach (XmlNode node in nodeList)
  {
      XmlNodeList nodeListAudio = node.SelectNodes("//pt:Actions", nsmgr);          
  
      Patient patient = new Patient(node["pt:NOAHPatientId"].InnerText, node["pt:Gender"].InnerText, node["pt:CreateDate"].InnerText);
  
      foreach (XmlNode nodeAudio in nodeListAudio)
      {
          Audiogram audiogramme = new Audiogram(nodeAudio["pt:TypeOfData"].InnerText, nodeAudio["pt:ActionDate"].InnerText);
          patient.audiogram.Add(audiogramme);                         
      }
      listPatient.Add(patient);               
  }
  dataGrid_XML.ItemsSource = listPatient;
  </code></pre>
  
  <pre>
  &lt;DataGrid x:Name="dataGrid_XML" AutoGenerateColumns="false" ItemsSource="{Binding Patient}"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTextColumn Binding="{Binding patientID}"  Header="ID Patient"/&gt;
          &lt;DataGridTextColumn Binding="{Binding genre}"  Header="Genre"/&gt;               
          &lt;DataGridTextColumn Binding="{Binding createDate}"  Header="Date création"/&gt;
          &lt;DataGridTextColumn Binding="{Binding audiogram.typeData}"  Header="Type de données"/&gt;
          &lt;DataGridTextColumn Binding="{Binding audiogram.actionData}"  Header="Date de dernière action"/&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </pre>