title: How to bind class with Dictionary<string,object> property to datagrid
body: <p>I have a scenario where i have to dynamically fetch the data and store it in a dictionary for display.</p>
  
  <p>This is how my Model looks like:</p>
  
  <pre><code>public class ViewModel
  {
     public Guid Id { get; set; }
     public string Name { get; set; }
     public Dictionary&lt;string,object&gt; CustomFields { get; set; }
  }
  </code></pre>
  
  <p>I am binding my view model to DataGrid and i have two columns defined for Id and Name.</p>
  
  <p>How do i generate columns for the data in the dictionary?</p>
  
  <p>I cannot use Dynamic object as i am using .net 3.5.</p>
  
  <p>This is how my XAML looks like:</p>
  
  <pre><code>&lt;Window x:Class="MyClass"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:tk="http://schemas.microsoft.com/wpf/2008/toolkit" 
          xmlns:viewmodel="clr-namespace:MyViewModel"
          xmlns:model="clr-namespace:MyModel"
          xmlns:sys="clr-namespace:System;assembly=mscorlib"
          Title="List Of Projects" Height="600" Width="600"&gt;
  
  &lt;Window.DataContext&gt;
      &lt;viewmodel:SomeViewModel&gt;&lt;/viewmodel:SomeViewModel&gt;
  &lt;/Window.DataContext&gt;
  
  &lt;tk:DataGrid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dgData" ItemsSource="{Binding ListOfObjects}"  VerticalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  AutoGenerateColumns="False"  SelectionMode="Single" CanUserAddRows="False" CanUserDeleteRows="False" &gt;
  
  &lt;tk:DataGrid.Columns&gt;
     &lt;tk:DataGridTextColumn Header="Id"  Binding="{Binding Id}" IsReadOnly="True"&gt;&lt;/tk:DataGridTextColumn&gt;
  
     &lt;tk:DataGridTextColumn Header="Name"  Binding="{Binding Name}" IsReadOnly="True"&gt;&lt;/tk:DataGridTextColumn&gt;
  &lt;/tk:DataGrid.Columns&gt;
  
  &lt;/tk:DataGrid&gt;
  
  &lt;/Window&gt;
  </code></pre>