title: Is it possible to data-bind a collector class with a dictionary property in xaml?
body: <p>I have a project where i need to add an unknown amount of columns to a datagrid. My thought is to have a dictionary included as a property in a collector class and the keys should be the column header. This might not be the proper way, but is my noob best guess to solve the issue. The collector class contains a couple of fixed parameters that should always be included and the dict of variables</p>
  <pre><code>public class ProfileCollector
  {
      public double Profile { get; set; }
      public double Ex { get; set; } = 0;
      public double Ey { get; set; } = 0;
      public double Ez { get; set; } = 0;
      public double Flip { get; set; } = 0;
      public Dictionary&lt;string, double&gt; Variables { get; set; } = new Dictionary&lt;string, double&gt;();
  }
      
  </code></pre>
  <p>When binding to Datagrid the all columns are added, including a column for Variables which is just represented by &quot;(Collection)&quot; in the rows.</p>
  <pre><code>&lt;Grid&gt;
      &lt;DataGrid x:Name=&quot;CustomizeDG&quot;
                ItemsSource = &quot;{Binding ProfileCollectors}&quot;&gt;
      &lt;/DataGrid&gt;
  &lt;/Grid&gt;
  </code></pre>
  <p>Is it possible make each key in the dict a new column with header=key and each cell in the following rows correspond to the value?</p>
  <p>Given <code>Variables = { {&quot;Input1&quot;, 0}, {&quot;Input2&quot;, 0} }</code> the columns should ideally be:</p>
  <pre><code>Profile | Ex | Ey | Ez | Flip | Input1 | Input2 
  </code></pre>
  <p>I tried to do as given in this <a href="https://programmersought.com/article/75062020930/" rel="nofollow noreferrer">example</a>, but came to short in my understanding of the binding to the Collection class.</p>
  <p>Any and all feedback are very appreciated.</p>