This is a migrated thread and some comments may be shown as answers.

Adding RadComboBox SelectedItems to ListBox Problem

1 Answer 125 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Bryce
Top achievements
Rank 1
Bryce asked on 05 Jan 2012, 02:29 AM
Hi,

Right now I have a RadComboBox with a ListBox next to it. What I want to happen is the user can type into the editable radcombobox and select the item they want in the drop down menu, or just click the dropdown button to open the drop down menu and select an item, and that item with be added to the ListBox. I thought this would be fairly simple, however, When I select an item in the drop down list when i type in it, the focus is still on the editable RadComboBox after the item is selected, and then if I delete whats in the editable combobox and start typing again, the RadComboBox drop down menu does not show up and it will automatically choose the first item closest to the text being typed and add it to the list. When I click the drop down button, it opens the drop down menu and I am able to add it to the list.

Here is my code:

<telerik:RadComboBox SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                                     ItemsSource="{Binding Contacts, Mode=TwoWay}"
                                     Style="{StaticResource ContactsComboBoxStyle}"/>

<Style x:Key="ContactsComboBoxStyle" TargetType="telerik:RadComboBox" >
        <Setter Property="Margin" Value="0 1 0 0" />
        <Setter Property="Grid.Column" Value="0" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="Height" Value="26" />
        <Setter Property="Width" Value="150" />
        <Setter Property="EmptyText" Value="Add Contact" />
        <Setter Property="IsEditable" Value="True" />
        <Setter Property="OpenDropDownOnFocus" Value="True" />
        <Setter Property="StaysOpenOnEdit" Value="True" />
        <Setter Property="IsTabStop" Value="True" />
        <Setter Property="IsFilteringEnabled" Value="True" />
        <Setter Property="TextSearchMode" Value="StartsWith" />
        <Setter Property="StaysOpenOnEdit" Value="True" />
        <Setter Property="OpenDropDownOnFocus" Value="True" />
        <Setter Property="IsMouseWheelEnabled" Value="True" />
        <Setter Property="CanAutocompleteSelectItems" Value="False" />
    </Style>

private ContactViewModel mSelectedItem;
        public ContactViewModel SelectedItem
        {
            get { return mSelectedItem; }
            set
            {
                mSelectedItem = value;
                if (mSelectedItem != null && !NewContacts.Contains(mSelectedItem))
                {
                    NewContacts.Add(mSelectedItem);
                }
                RaisePropertyChanged("SelectedItem");
            }
        }


Is there a way to fix this?

Thanks,
Bryce

[EDIT]

I noticed the same thing happened with the first RadComboBox in your demos:

http://demos.telerik.com/silverlight/#ComboBox/EditableMode 

What happens is when I click the drop down, the drop down menu will open, and then when I start typing it will go to the correct RadComboBoxItem and then when I press enter, the SelectedItem will be displayed in the RadComboBox. However, if I start typing after pressing enter, the drop down menu will not open, but it will Select a different item in the RadComboBox based on what I was typing. What I want is to be able to have the drop down menu open again, and have the user be able to see their options and down arrow click to the new item they want to select.

Thanks again.

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 06 Jan 2012, 04:48 PM
Hello Bryce,

The default behavior of RadComboBox is to keep its drop-down closed unless the user explicitly opens it via a mouse click or pressing PgDown. I created a simple attached behavior that opens the drop-down when the user types text, please find attached a sample application.

I hope this helps.

Regards,
Valeri Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ComboBox
Asked by
Bryce
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or