title: How to display objects with dynamic fields in wpf data grid?
body: <p>I want to display and edit some objects in a WPF data grid and I'm looking for a good way to do so. All objects I want to display have the same fields, but every execution the fields of my objects can differ. Here is a piece of the interface to illustrate what I mean:</p>
  
  <pre><code>public interface IMyObject
  {
      IEnumerable&lt;string&gt; GetFieldNames();
      IEnumerable&lt;Type&gt; GetFieldTypes();
  
      object GetField(string name);
      void SetField(string name, object value);
  }
  </code></pre>
  
  <p>How can I generate a data grid which displays this kind of objects? I thought of XAML generation to define the columns, but I'm still facing the problem of accessing the fields. I think I could realize this with value converters, another option would be to dynamically create a type which exposes the dynamic fields with properties.</p>
  
  <p>Are there any other ways and which should I favor? I'm keen on hearing your opinions.</p>
  
  <p>Best Regards,<br>
  Oliver Hanappi</p>