title: WPF Databinding to generic List<>
body: <p>I am doing something wrong .. you know how it is.</p>
  
  <p>I have tried playing around with ItemsSource , DataContext , DisplayMemberPath and SelectedValuePath and I either get a blank list of a list of the ToString method being called in the Person object;</p>
  
  <p>WHAT WOULD REALLY HELP is for someone to publish an answer that works for this example.</p>
  
  <p>I have simplified the problem as I am having difficulty in general with databinding generics.</p>
  
  <p>I have created a simple Generic List of Person and want to bind it to a combo. (also want to try use a ListView too).</p>
  
  <p>I either get a list of blanks or a list of  'xxxx.Person' where xxxx = namespace</p>
  
  <pre><code>       &lt;Window x:Class="BindingGenerics.MainWindow"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  Title="MainWindow" Height="300" Width="300"&gt;
              &lt;Grid&gt;
  
                  &lt;ComboBox Name="ComboBox1"
                            ItemsSource="{Binding}"
                            Height="50"
                            DisplayMemberPath="Name"
                            SelectedValuePath="ID"
                            FontSize="14"
                            VerticalAlignment="Top"&gt;
                  &lt;/ComboBox&gt;
  
              &lt;/Grid&gt;
          &lt;/Window&gt;
  
  
  
  using System.Windows;
  using System.ComponentModel;
  
  namespace BindingGenerics
  {
      /// &lt;summary&gt;
      /// Interaction logic for MainWindow.xaml
      /// &lt;/summary&gt;
      public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
  
              Person p = new Person();
              // I have tried List and BindingList
              //List&lt;Person&gt; list = new List&lt;Person&gt;();
              BindingList&lt;Person&gt; list = new BindingList&lt;Person&gt;();
  
              p.Name = "aaaa";
              p.ID = "1111";
              list.Add(p);
  
              p = new Person();
              p.Name = "bbbb";
              p.ID = "2222";
              list.Add(p);
  
              p = new Person();
              p.Name = "cccc";
              p.ID = "3333";
              list.Add(p);
  
              p = new Person();
              p.Name = "dddd";
              p.ID = "4444";
              list.Add(p);
  
              ComboBox1.DataContext = list;
          }
      }
  
      public struct Person
      {
          public string Name;
          public string ID;
      }
  }
  </code></pre>