title: C# WPF How to bind a nested class to nested datagrid in "Datagrid Row-Details"?
body: <p>How to bind data from nested classs to a nested datagrid? Why nested datagrid unable to read the class? what error i am doing?</p>
  
  <pre><code>    public class Student
      {
          public int Id { get; set; }
          public string Name { get; set; }
          public DateTime Birthday { get; set; }
          public Marks myMarks { get; set; }
      }
  
      public class Marks
      {
          public double English { get; set; }
          public double Maths { get; set; }
          public double Science { get; set; }
      }
  </code></pre>
  
  <p>itemsource for main-datagrid</p>
  
  <pre><code>private void Page_Loaded(object sender, RoutedEventArgs e)
  {
     List&lt;Student&gt; myStudents = new List&lt;Student&gt;();
  
      Marks JohnMark = new Marks();
      JohnMark.English = 75;
      JohnMark.Maths = 85;
      JohnMark.Science = 95;
  
      Marks RichardMark = new Marks();
      RichardMark.English = 70;
      RichardMark.Maths = 80;
      RichardMark.Science = 90;
  
      Marks SamMark = new Marks();
      SamMark.English = 72;
      SamMark.Maths = 82;
      SamMark.Science = 92;
  
      myStudents.Add(new Student() { Id = 1, Name = "John Doe", Birthday = new DateTime(1971, 7, 23), myMarks = JohnMark });
      myStudents.Add(new Student() { Id = 2, Name = "Richard Doe", Birthday = new DateTime(1974, 1, 17), myMarks = RichardMark });
      myStudents.Add(new Student() { Id = 3, Name = "Sammy Doe", Birthday = new DateTime(1991, 9, 2), myMarks = SamMark });
  
      DG_myStudents.ItemsSource = myStudents;
  }
  </code></pre>
  
  <p>and below is my XAML code, Am i doing any error in class structure? Please help me.</p>
  
  <pre><code>   &lt;DataGrid x:Name="DG_myStudents" RowDetailsVisibilityMode="Visible"&gt;
          &lt;DataGrid.RowDetailsTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;DataGrid x:Name="DG_myMarks" ItemsSource="{Binding myMarks}" /&gt;
              &lt;/DataTemplate&gt;
          &lt;/DataGrid.RowDetailsTemplate&gt;
      &lt;/DataGrid&gt;
  </code></pre>