Can't Close RadAutoCompleteBox when Manually Opened in _GotFocus Event

2 posts, 0 answers
  1. The Bearded One
    The Bearded One avatar
    6 posts
    Member since:
    Oct 2014

    Posted 04 Aug Link to this post

    We are trying to use a RadAutoCompleteBox on a Windows tablet. The use case is that a user needs to tap the field to open it and see all the results. This works fine. When the field is tapped, we do something like this...

    public void SomeField_GotFocus(object sender, RoutedEventArgs e)
    {
       var autoCompleteBox = sender as RadAutoCompleteBox;
           if (autoCompleteBox != null && !autoCompleteBox.IsDropDownOpen)
       {
            autoCompleteBox.Suggest(autoCompleteBox.Text);
       }
    }

    After an item is selected, this event is fired

    public void SomeField_SelectionChanged(object sender, SelectionChangedEventArgs e)

     

    ...the Telerik control puts the cursor (focus) back in the original field, which fires the _GotFocus event again, which opens the autocomplete list again.

    In this cycle, it isn't possible to get the RadAutoCompleteBox to close.

     

    Looking at the API i don't see any methods to explicitly close the list.

    I could work around it if I could get any other event (non-GotFocus) to fire when the control is selected, but I haven't been able to get the RadAutoCompleteBox to respond to _Tapped or _Click type events.

    Anyone have any ideas?

     

    Requirements I'm Trying to Satisfy

    - RadAutoCompleteBox must open on tap (whether there is data in the field or not)

    - Selecting item should set the value and close the item list

     

  2. Nasko
    Admin
    Nasko avatar
    693 posts

    Posted 07 Aug Link to this post

    Hi Mark,

    In order to achieve the desired behavior of RadAutoCompleteBox you could handle the Tapped event of the TextBox placed inside the control and call the Suggest method from inside it.

    Please, check the attached sample that demonstrates the described above approach.

    Hope this helps.

    Regards,
    Nasko
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top