title: Binding List of Object to DataGrid
body: <p>I'm trying to bind a list of objects to a DataGrid on the compact framework. This is what I have:</p>
  
  <pre><code>public class Order
  {
      //Other stuff
      public Customer Customer
      {
          get { return _customer; }
      }
  }
  
  public class Customer
  {
      //Other stuff
      public string Address
      {
          get { return _address; }
      }
  }
  </code></pre>
  
  <p>Now I want to bind the DataGrid to a list of Order and display only certain properties (the customer's address is one of them):</p>
  
  <pre><code>List&lt;Order&gt; orders = MethodThatGetsOrders();
  datagrid.DataSource = orders;
  datagrid.TableStyles.Clear();
  DataGridTableStyle ts = new DataGridTableStyle();
  ts.MappingName = orders.GetType().Name; //This works OK
  DataGridTextBoxColumn tb = new DataGridTextBoxColumn();
  tb.MappingName = orders.GetType().GetProperty("Customer").GetType().GetProperty("Address").Name; //Throws NullRef
  ts.GridColumnStyles.Add(tb);
  datagrid.TableStyles.Add(ts);
  </code></pre>
  
  <p>How can I display the customer's address on the DataGridTextBoxColumn?<br>
  Thanks</p>