title: WPF - Bind combobox to List of custom class objects
body: <p>I have a WPF project with a combobox that I'm trying to bind to a List of <code>ComboboxItem</code> objects.  <code>ComboboxItem</code> is a class that I created for my sample project.  This is partially working...  I have my three items available to the combobox, but the displayed value is blank and the value of <code>combobox.SelectedValue</code> is null.  I've seen several stackoverflow posts and other blog posts about how to do this.  And as far as I can tell, I'm doing this right.  But obviously I'm doing something wrong.  Here is the source code for a test project...</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window x:Class="WpfTestApp_ComboBoxes.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"
          Loaded="Window_Loaded"&gt;
      &lt;Grid&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="40"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;ComboBox x:Name="cboMyCombo" Grid.Row="0" 
                    SelectionChanged="cboMyCombo_SelectionChanged"&gt;&lt;/ComboBox&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>C# Code-behind:</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      List&lt;ComboboxItem&gt; _list = new List&lt;ComboboxItem&gt;();
  
      public MainWindow()
      {
          _list.Add(new ComboboxItem() { DisplayValue = "One", InternalValue = "1" });
          _list.Add(new ComboboxItem() { DisplayValue = "Two", InternalValue = "2" });
          _list.Add(new ComboboxItem() { DisplayValue = "Three", InternalValue = "3" });
  
          InitializeComponent();
      }
  
      private void cboMyCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
          if (e.AddedItems.Count &gt; 0)
          {
              ComboBox cb = sender as ComboBox;
              MessageBox.Show(string.Format("Selected Item: {0}, Selected Value: {1}", cb.SelectedItem, cb.SelectedValue));
          }
      }
  
      private void Window_Loaded(object sender, RoutedEventArgs e)
      {
          cboMyCombo.ItemsSource = _list;
          cboMyCombo.DisplayMemberPath = "DisplayValue";
          cboMyCombo.SelectedValuePath = "InternalValue";
      }
  }
  </code></pre>
  
  <p>ComboboxItem Class:</p>
  
  <pre><code>public class ComboboxItem
  {
      public string DisplayValue;
      public string InternalValue;
  }
  </code></pre>