title: Is there a way to dynamically bind properties /variables to objects in C# WPF DataGrid
body: <p>I am writing myself a small Tool that helps me binding Joysticks for Flight simulators. As each axis has to be bound separately in the game, this i want to solve with my tool on a high level.
  Long story short, I need to read in text files with data which tells the tool how many planes there currently exist and if i want to have the joystick bind also for that plane.</p>
  <p>So in order for the user to tell if his profile applies also to this he needs to hit a checkbox or not.
  So creating headers and the columns at runtime is no issue and can be done with this.</p>
  <pre><code>void InitDGSelected()
     {
       DataGridTextColumn IdTxtColumn = new DataGridTextColumn();
       IdTxtColumn.Header = &quot;ID&quot;;
       IdTxtColumn.Binding = new Binding(&quot;ID&quot;);
       DGAdded.Columns.Add(IdTxtColumn); //DGAdded is the DataGrid
       for(int i=1; i&lt;MainStructure.Planes.Length; ++i)
       {
           DataGridCheckBoxColumn pcbc = new DataGridCheckBoxColumn();
           pcbc.Header = MainStructure.Planes[i];
           pcbc.Binding = new Binding(MainStructure.Planes[i]);
           pcbc.IsReadOnly = false;
           DGAdded.Columns.Add(pcbc);
       }    
     }
  </code></pre>
  <p>However populating it with Data is where my issue starts.
  WPF needs property objects which always have a fixed length at runtime as they got compiled e.g. like this one i am using:</p>
  <pre><code>public class SearchQueryResults
     {
         public string ID { get; set; }
         public string AIRCRAFT { get; set; }
         public string DESCRIPTION { get; set; }
     }
  </code></pre>
  <p>But as I don't want to compile with each game patch or change my Tool again, I'd like to know if there is a way to dynamically have an object with dynamic bindings.
  I tried already</p>
  <pre><code>Dictionary&lt;object, object&gt; plswork = new Dictionary&lt;object, object&gt;();
      plswork.Add(&quot;ID&quot;, ri[i].ID);
      for (int j = 1; j &lt; MainStructure.Planes.Length; ++j)
      {
          if (ri[i].GetStateAircraft(MainStructure.Planes[i]) == PlaneState.ACTIVE)
              plswork.Add(MainStructure.Planes[i], true);
          else if(!plswork.ContainsKey(MainStructure.Planes[i]))
              plswork.Add(MainStructure.Planes[i], false);
      }
      DGAdded.Items.Add(plswork);
  </code></pre>
  <p>The same with &lt;string, object&gt; or a one dimensional array with one string followed by bools that should have the same bitlength, but yeah im stuck.
  Please someone help!</p>
  <p>Cheers!</p>