title: How do you get the proper mapping name from a binding source bound to a List<T>, or an anonymous type, to use on a DataGridTableStyle?
body: <p>I'm trying to create a DataGridTableStyle object so that I can control the column widths of a DataGrid. I've created a BindingSource object bound to a List. Actually it's bound to an anonymous type list created though Linq in the following manner (variable names changed for clarity of what I'm doing):</p>
  
  <pre><code>List&lt;myType&gt; myList = new List&lt;myType&gt;(someCapacity);
  .
  ...populate the list with query from database...
  .
  
  var query = from i in myList
              select new
              {
                  i.FieldA,
                  i.FieldB,
                  i.FieldC
              };
  
  myBindingSource.DataSource = query;
  myDataGrid.DataSource = myBindingSource;
  </code></pre>
  
  <p>Then I create a DataGridTableStyle object and add it to the datagrid. However, it never applies my table style properties I set up because I can't seem set the proper myDataGridTableStyle.MappingName property.</p>
  
  <p>I've searched Google for about 1/2 an hour and keep seeing links to the same question throughout a bunch of different forums (literally the same text, like someone just copied and pasted the question... I hate that...). Anyway, none of the suggestions work, just like the guy says on all the other sites.</p>
  
  <p>So does anybody here know what I need to set the MappingName property to in order to have my TableStyle actually work properly? Where can I grab the name from? (It can't be blank... that only works with a BindingSource that is bound to a DataTable or SqlCeResultSet etc.). </p>
  
  <p>I'm thinking it could be an issue with me using Linq to create an anonymous, more specialized version of the objects with only the fields I need. Should I just try to bind the BindingSource directly to the List object? Or maybe even bind the DataGrid directly to the List object and skip the binding source altogether.</p>
  
  <p>Thanks</p>
  
  <p>PS - C#, Compact Framework v3.5</p>
  
  <p>UPDATE:</p>
  
  <p>I've posted an answer below that solved my problem. Whether or not it's the best approach, it did work. Worth a peek if you're having the same issue I had.</p>