autocompletebox.focus

6 posts, 0 answers
  1. Kevin
    Kevin avatar
    12 posts
    Member since:
    Oct 2013

    Posted 09 Oct 2013 Link to this post

    hi im a new developer to silverlight/ui controls.  basically, after triggering an event such as a button click, i want to set focus to my telerik autocompletebox.  I tried the function autcompletebox.focus but that doesnt work.  I was wondering if there is a simple xaml or c# code that will do the trick similiar to textbox.select, which seems to work fine.

  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 11 Oct 2013 Link to this post

    Hi,

    You can take a look at our OpenWithDropDownButton example that is available in our online SDK repository. In that project in order to set the focus to the RadAutoCompleteBox all you need to do is call its Focus() method.

    You can download the entire repository as a zip file via this link.

    Regards,
    Vladi
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Kevin
    Kevin avatar
    12 posts
    Member since:
    Oct 2013

    Posted 11 Oct 2013 Link to this post

    my apologies, i did not give the full context of what i am trying to do.  I do not actually want to focus the aucompletebox through clicking a button.  I basically have a overlay textblock that serves the purpose of a placeholder text (enter customer name here).  when the user clicks the textblock, it collapses so the user can enter text into the aucomplete box underneath.

    the problem is the user currentely has to click twice (once to collapse the textbox and once to select the autocompletebox).  That is why I was asking about the .focus method, since it would be perfect if i can call that in the same event that collapse the overlay textbox.
  5. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 14 Oct 2013 Link to this post

    Hello,

    You should know that the RadAutoCompleteBox has a property that could be set in order to show a watermark text in the control. You can set the WatermarkContent to any text you desire.

    If using that build-in property is not applicable in your project could you give us more details on why you prefer add a placeholder TextBox control that is placed above the control as that could cause issues when interacting with the control?

    Regards,
    Vladi
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Jeff
    Jeff avatar
    1 posts
    Member since:
    Mar 2015

    Posted 04 Mar 2015 in reply to Vladi Link to this post

    Hi Vladi,

    I'm having trouble setting focus on the RadAutoCompleteBox as well. I was able to get it to work as an independent control, like in the example you mentioned. I'm trying to use RadAutoCompleteBox along with a RadRichTextBox. I have the ACB and RTB on top of each other in a grid container in the XAML. When the user presses a key in the RTB, if it's a certain key word I want to show the ACB, populate it with the key the user typed and let them use the ACB to autocomplete what they were typing. It all works except I can't get the RTB to give up focus. I call the ACB.Focus() function and the RTB cursor still has focus. How do I get the RTB to give up focus to the ACB programmatically? It works if I use the mouse to click on the ACB, but I don't want my use to have to take they're hands off the keyboard. Here's the code snippet:

    AutoCompleteBox.SearchText = m_currentWord.ToUpper();
    AutoCompleteBox.Focus();
    object focus = FocusManager.GetFocusedElement();
    AutoCompleteBox.Populate(AutoCompleteBox.SearchText); 

    If I look at 'focus' the Caret still has focus.

    Thanks for your help!
  7. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 09 Mar 2015 Link to this post

    Hi Jeff,

    Thank you for contacting us.

    When setting the focus to the RadAutoCompleteBox from a RadRichTextBox control indeed the RichTextBox's caret does not disappear. Other that that visual effect the observed behavior was correctly triggered and the input string was taken from the RichTextBox and passed to AutoCompleteBox correctly.

    I recorded a short video for you showing the observed scenario on our side. Could you verify that this is the visual caret (focus) issue you are experiencing? You can also find the sample test project used in the video attached to my response.

    If we have missed something please respond to us in a separate support thread where we can continue the discussion in greater details.

    Regards,
    Vladi
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
DevCraft banner