Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
625
WPF XamComboEditor do not add the new item
posted

Hi,

I am using the XamComboEditor (Infragistics.Controls.Editors) in order to create an AutoCompleteBox.

The following show my autocompletebox:

    public class AutoCompleteBox : XamComboEditor
    {
        public int MruListMax
        {
            get { return (int)GetValue(MruListMaxProperty); }
            set { SetValue(MruListMaxProperty, value); }
        }
        // Using a DependencyProperty as the backing store for MruListMax.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MruListMaxProperty =
            DependencyProperty.Register("MruListMax", typeof(int), typeof(AutoCompleteBox), new PropertyMetadata(50));
        public AutoCompleteBox()
        {
            this.CustomValueEnteredAction = CustomValueEnteredActions.Add;
            DropDownButtonDisplayMode = DropDownButtonDisplayMode.Never;
        }
        protected override void OnItemAdded(ComboEditorItem item)
        {
            base.OnItemAdded(item);
           
            ObservableCollection<string> itemSourceLIst = this.ItemsSource as ObservableCollection<string>;
            if (itemSourceLIst.Count > MruListMax)
            {
                itemSourceLIst.RemoveAt(0);
            }
        }
    }
And the AutocompleteBox has been added to the view as shown here:
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Controls:AutoCompleteBox ItemsSource="{Binding MruList}" VerticalAlignment="Top" />
        <ListBox ItemsSource="{Binding MruList}"
                 Grid.Column="1" />
     
    </Grid>
My problem is that i do not add the correct new item. If my MruList contains the following : Dennis, Denny, and I enter "Denni" in the comboBoxEditor, the when I click Enter or uses Tab, it do not add "Denni" to the MruList, instead it chooses "Dennis" which are already in the list?
How can I prevent it from suggesting "Dennis", when i only type in "Denni"?
Best Regards!
Dennis
Using 15.1

Parents
No Data
Reply
  • 17475
    Offline posted

    Hello Dennis,

    When the AutomComplete feature is enabled the first item that match the currently entered text in XamComboEditor will be activated so if the user press enter it will be selected. In case the user does not want to select that item they can press Esc key to remove the active item from the drop down. Then on enter key the new item will be added to the data source.

    Please feel free to let me know if you have any questions or concerns.

Children