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

autocompletebox.focus

5 Answers 88 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 09 Oct 2013, 01:48 PM
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.

5 Answers, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 11 Oct 2013, 12:49 PM
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 >>
0
Kevin
Top achievements
Rank 1
answered on 11 Oct 2013, 01:37 PM
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.
0
Vladi
Telerik team
answered on 14 Oct 2013, 08:30 AM
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 >>
0
Jeff
Top achievements
Rank 1
answered on 04 Mar 2015, 11:43 PM
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!
0
Vladi
Telerik team
answered on 09 Mar 2015, 09:30 AM
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.

 
Tags
AutoCompleteBox
Asked by
Kevin
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Kevin
Top achievements
Rank 1
Jeff
Top achievements
Rank 1
Share this question
or