title: WPF binding List<KeyValuePair<,>> to DataGrid using XAML
body: <p>I want to display all the NetworkInterfaces of my computer via DataGrid and i have the following class for (that is the .xaml.cs Controller):</p>
  
  <pre><code>public partial class Network : Window
  {
      public Network()
      {
          PrintStatus();
          InitializeComponent();
      }
  
      public void PrintStatus()
      {
          var bindingList = new List&lt;KeyValuePair&lt;string, object&gt;&gt;();
  
          foreach (NetworkInterface card in networkCards)
          {
              foreach (PropertyInfo prop in typeof(NetworkInterface).GetProperties())
                  bindingList.Add(new KeyValuePair&lt;string, object&gt;(prop.Name, prop.GetValue(card, null)));
          }
      }
  }
  </code></pre>
  
  <p>I tried like following, but that doesn't work:</p>
  
  <pre><code>&lt;DataGrid x:Name="NetInfo" ItemsSource="{Binding Source=bindingList}"&gt;
      &lt;DataGrid.Columns&gt;    
          &lt;DataGridTextColumn Header="Key" Binding="{Binding Key}"/&gt;
          &lt;DataGridTextColumn Header="Value" Binding="{Binding Value}"/&gt;    
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>In VisualStudio when i move my mouse over Key or Value in the <code>Binding</code> tag i get the message that <strong><em>it cannot be resolved due to unknow DataContext</em></strong>.</p>
  
  <p>Can someone please tell me what i am doing wrong so, as you can see i don't really understand how Databindings work ^^.</p>