title: Binding custom list object properties to textbox from code behind
body: <p><strong>Student class</strong>  </p>
  
  <pre><code>public class Student
  {
      string name;        
  
      List&lt;SubjectInfo&gt; subjectInfoList;        
  
      ....
  }
  </code></pre>
  
  <p><code>List&lt;SubjectInfo&gt;</code> List can have different number of <code>SubjectInfo</code> objects for different students.    </p>
  
  <p><strong>SubjectInfo class</strong>  </p>
  
  <pre><code>public class SubjectInfo
  {
      string subjectCode;
  
      int marks;
  
      ...
  }
  </code></pre>
  
  <p>I want to display student object detail on a window. Since <strong>List</strong> have different number of object count I generated these from code behind.  </p>
  
  <pre><code>int i = 10;
  
          foreach (SubjectInfo info in student.SubjectInfoList)
          {
              TextBox tb = new TextBox();
              tb.Width = 200;
              tb.Height = 20;
              tb.Margin = new Thickness(10, i, 0, 0);
              StudentDataGrid.Children.Add(tb);
              i += 60;
          }
  </code></pre>
  
  <p>I would like to bind this <strong>List</strong> list from code behind. But I have no idea of doing that.<br>
  I want to bind <strong>marks</strong> property of <code>student.SubjectInfoList</code>  </p>
  
  <p>Please help me with binding list object properties from codebehind.  </p>
  
  <p><strong>EDIT</strong><br>
  This is the sample student object;  </p>
  
  <pre><code>Student student = new Student("Joe", new List&lt;SubjectInfo&gt;() { new SubjectInfo("Subject1", 50), new SubjectInfo("Subject2", 70)});  
  </code></pre>
  
  <p>My window should like this;<br>
  <img src="https://i.stack.imgur.com/HyR6s.jpg" alt="enter image description here">  </p>
  
  <p><strong>NOTE</strong> if student doing 4 subjects total <code>TextBox</code> count is 5.</p>