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

Allow Custom Entry?

1 Answer 142 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Bruno
Top achievements
Rank 1
Bruno asked on 07 Nov 2012, 02:24 PM
Hi Telerik Team,

In the Ajax version of the RadAutoCompleteBox it is possible to add custom entry by the Property "AllowCustomEntry".
In the Silverlight version of the RadAutoCompleteBox this Property doesn't exist.

Is it scheduled to add this additional feature? Or is there a workaround available for this feature?

Kind regards,
Bruno

1 Answer, 1 is accepted

Sort by
0
Ivo
Telerik team
answered on 12 Nov 2012, 12:00 PM
Hi Bruno,

We think that creating objects from simple text should not be handled by the RadAutoCompleteBox. However this scenario could be easily achieved. Handling the KeyDown event should do the trick. Here is sample code:
private void OnKeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Enter)
    {
        var autoComplete = (RadAutoCompleteBox)sender;
        if (!string.IsNullOrEmpty(autoComplete.SearchText))
        {
            var viewModel = (ViewModel)autoComplete.DataContext;
            var item = new Item() { Id = Guid.NewGuid(), Name = autoComplete.SearchText };
 
            viewModel.SelectedItems.Add(item);
            autoComplete.SearchText = string.Empty;
        }
    }
}


Regards,
Ivo
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
AutoCompleteBox
Asked by
Bruno
Top achievements
Rank 1
Answers by
Ivo
Telerik team
Share this question
or