3 Answers, 1 is accepted
0
Hello James,
To set the focus on a control you need to make sure that the control you want to be focused is loaded before setting the focus on it. Here is a sample method that puts the focus on the passed focusControl:
Hope this helps.
Kind regards,
Vladi
the Telerik team
To set the focus on a control you need to make sure that the control you want to be focused is loaded before setting the focus on it. Here is a sample method that puts the focus on the passed focusControl:
private void PutFocus(Control focusControl){ if (focusControl != null) { RoutedEventHandler loadedEventHandler = null; loadedEventHandler = new RoutedEventHandler(delegate { focusControl.Loaded -= loadedEventHandler; focusControl.Focus(); }); focusControl.Loaded += loadedEventHandler; }}Hope this helps.
Kind regards,
Vladi
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
James B.
Top achievements
Rank 1
answered on 06 Jul 2012, 08:21 PM
Thanks for the code. It still isn't working for me. The control is in the xaml and the window only has 1 field and 2 buttons so not sure what's up.
0
Hi James,
I have prepared and attached a sample project representing the described approach on how to set the focus on specific control. In the attached project the focus is set to textBox2.
Take a look at it and tell me if you are doing something different in your project.
Kind regards,
Vladi
the Telerik team
I have prepared and attached a sample project representing the described approach on how to set the focus on specific control. In the attached project the focus is set to textBox2.
Take a look at it and tell me if you are doing something different in your project.
Kind regards,
Vladi
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>