title: Custom navigable combo box control
body: <p>I am trying to build a custom combobox with forward and back buttons I am starting out and I am having trouble with being able to populate the combobox with generic lists.</p>
  <p>so far I have this:</p>
  <p>public partial class NavigableComboBox : UserControl, INotifyPropertyChanged
  {</p>
  <pre><code>#region Constructor
  
  public NavigableComboBox()
  {
      InitializeComponent();
  }
  
  #endregion
  
  #region Dependency Properties
  
  #region ListSource
  
  [System.Diagnostics.CodeAnalysis.SuppressMessage(&quot;Microsoft.Usage&quot;, &quot;CA2227:CollectionPropertiesShouldBeReadOnly&quot;)]
  public ObservableCollection&lt;object&gt; ListSource
  {
      get
      {
          return (ObservableCollection&lt;object&gt;)GetValue(ListSourceProperty);
      }
      set
      {
          base.SetValue(NavigableComboBox.ListSourceProperty, value);
          NotifyPropertyChanged(&quot;ListSource&quot;);
      }
  }
  
  [System.Diagnostics.CodeAnalysis.SuppressMessage(&quot;Microsoft.Usage&quot;, &quot;CA2211:NonConstantFieldsShouldNotBeVisible&quot;)]
  public static DependencyProperty ListSourceProperty = DependencyProperty.Register(
       &quot;ListSource&quot;,
       typeof(ObservableCollection&lt;object&gt;),
       typeof(NavigableComboBox),
       new PropertyMetadata(OnValueChanged));
  
  #endregion
  
  #region ListSource
  
  public object SelectedItem
  {
      get
      {
          return (object)GetValue(SelectedItemProperty);
      }
      set
      {
          base.SetValue(NavigableComboBox.SelectedItemProperty, value);
          NotifyPropertyChanged(&quot;SelectedItem&quot;);
      }
  }
  
  public static DependencyProperty SelectedItemProperty = DependencyProperty.Register(
      &quot;SelectedItem&quot;,
      typeof(object),
      typeof(NavigableComboBox),
      new PropertyMetadata(OnValueChanged));
  
  #endregion
  
  #endregion
  
  private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  {
      ((NavigableComboBox)d).ListSource = (ObservableCollection&lt;object&gt;)e.NewValue;
  }
  
  public event PropertyChangedEventHandler PropertyChanged;
  public void NotifyPropertyChanged(string propertyName)
  {
      if (PropertyChanged != null)
      {
          PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
      }
  }
  </code></pre>
  <p>}</p>
  <p>and this for xaml:</p>
  <pre><code>&lt;UserControl x:Class=&quot;Divestco.WinPics.Components.Common.UserControls.NavigableComboBox&quot;
               xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
               xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
               xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot; 
               xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
               xmlns:local=&quot;clr-namespace:Divestco.WinPics.Components.Common.UserControls&quot;
               mc:Ignorable=&quot;d&quot; 
               d:DesignHeight=&quot;55&quot; d:DesignWidth=&quot;200&quot;&gt;
          &lt;Grid&gt;
  &lt;ComboBox Name=&quot;comboBox1&quot; ItemsSource=&quot;{Binding ListSource}&quot; SelectedItem=&quot;{Binding SelectedItem}&quot; /&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  <p>And I am using it as so on the main form:</p>
  <pre><code>&lt;UserControls:NavigableComboBox ListSource=&quot;{Binding Path=MapModel.GridsInProject}&quot; SelectedItem=&quot;{Binding Path=MapModel.SelectedGrid}&quot;/&gt;
  </code></pre>
  <p>I place break points on the dependency property but they are never hit. When using a regular combobox and not my custom control it is filled with out a problem so I know the main form bindings are correct. I also am not getting any error messages when running</p>
  <p>Does anyone know what I am doing wrong? or even better does anyone know of a pre made control like this?</p>
  <p><strong>The control I envision will have a combobox and a next previous button on either side. The user can select an item from the dropdown list or scroll through by pressing next or previous. The control should be able to take any custom collection of objects and allow you to choose the display field. For example I have a collection of grid objects and a collection of horizon objects and I will populate the control with one of them depending on other factors in the app. Both collections have a string property named &quot;Name&quot; that will be the display field.</strong></p>
  <p><img src="https://i.stack.imgur.com/qkb48.jpg" alt="enter image description here" /></p>