Allow Custom Entry?

2 posts, 0 answers
  1. Bruno
    Bruno avatar
    54 posts
    Member since:
    Jul 2012

    Posted 07 Nov 2012 Link to this post

    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
  2. Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 12 Nov 2012 Link to this post

    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.

  3. DevCraft banner
Back to Top