Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom navigable combo box control
    primarykey
    data
    text
    <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("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public ObservableCollection&lt;object&gt; ListSource { get { return (ObservableCollection&lt;object&gt;)GetValue(ListSourceProperty); } set { base.SetValue(NavigableComboBox.ListSourceProperty, value); NotifyPropertyChanged("ListSource"); } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2211:NonConstantFieldsShouldNotBeVisible")] public static DependencyProperty ListSourceProperty = DependencyProperty.Register( "ListSource", 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("SelectedItem"); } } public static DependencyProperty SelectedItemProperty = DependencyProperty.Register( "SelectedItem", 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="Divestco.WinPics.Components.Common.UserControls.NavigableComboBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Divestco.WinPics.Components.Common.UserControls" mc:Ignorable="d" d:DesignHeight="55" d:DesignWidth="200"&gt; &lt;Grid&gt; &lt;ComboBox Name="comboBox1" ItemsSource="{Binding ListSource}" SelectedItem="{Binding SelectedItem}" /&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="{Binding Path=MapModel.GridsInProject}" SelectedItem="{Binding Path=MapModel.SelectedGrid}"/&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 "Name" that will be the display field.</strong></p> <p><img src="https://i.stack.imgur.com/qkb48.jpg" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload