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

Focus on border clicked

2 Answers 50 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 23 Sep 2014, 06:12 AM
What is the best way to make this control focus when the border is clicked? I'm am noticing that the cursor is changed to the i-beam when the mouse hovers over the border of the control, but clicking does not focus on the control. 

(Note, this behaviour is present in both the Masked input boxes, and the Auto complete boxes and I've duplicated the post in both forums)

Version 2014.2.729.1050

2 Answers, 1 is accepted

Sort by
0
Alex
Top achievements
Rank 1
answered on 23 Sep 2014, 06:16 AM
To see this behaviour simply create a control with a large border
e.g.

<telerik:RadAutoCompleteBox SearchText="auto" BorderThickness="10"/>
<telerik:RadMaskedCurrencyInput SelectionOnFocus="SelectAll" BorderThickness="10" />
<telerik:RadMaskedDateTimeInput SelectionOnFocus="SelectAll" BorderThickness="10" />
<telerik:RadMaskedNumericInput SelectionOnFocus="SelectAll" BorderThickness="10" />
<telerik:RadMaskedTextInput SelectionOnFocus="SelectAll" BorderThickness="10" />
0
Kalin
Telerik team
answered on 25 Sep 2014, 01:43 PM
Hi Alex,

What I can suggest you in order to achieve this particular scenario, would be to hook to the MouseLeftButtonDown event of the AutoCompleteBox. Inside of the handler you would be able to manually focus the control and in addition to this you can select the text inside by getting the WatermarkTextBox from the ControlTemplate of the AutoCompleteBox. Please check the following code snippet:

private void Auto_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    var autoCompleteBox = sender as RadAutoCompleteBox;
    autoCompleteBox.Focus();
    var txtBox = autoCompleteBox.ChildrenOfType<RadWatermarkTextBox>().First();
    txtBox.SelectAll();
}

Hope this helps.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
AutoCompleteBox
Asked by
Alex
Top achievements
Rank 1
Answers by
Alex
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or