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

RadMaskedTextInput.Focus()

3 Answers 32 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
WILLIAM
Top achievements
Rank 1
WILLIAM asked on 20 Mar 2014, 02:30 PM
Good Morning Telerik Team,

I'm having trouble setting the focus to a RadMaskesTextInput control.  I have found various suggestions, but none have seemed to work for me.  I currently have the latest relase 2014 Q1.

I'm subscribing to events on the view for GotFocus and Loaded.  Both of these events fire and call my code to set the focus.

I have tried the follow:
1. control.Focus();
2. control.SetValue(RadMaskedTextInput.IsFocusedProperty, true);
3. control.Focus();
    control.SetValue(RadMaskedTextInput.IsFocusedProperty, true);
4. control.SetValue(RadMaskedTextInput.IsFocusedProperty, true);
    control.Focus();

None of these work; However, in the same method if I can call PasswordControl.Focus() or ButtonControl.Focus() and they both work.  So, it seems to be a problem with the RadMaskedTextInput control.

Thanks for your help!

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 25 Mar 2014, 07:34 AM
Hello William,

It is not very easy to achieve this focusing even with standard TextBox. Based on the suggestions from this thread I tried the following workaround:
private void RadMaskedTextInput_Loaded(object sender, RoutedEventArgs e)
      {
          System.Windows.Browser.HtmlPage.Plugin.Focus();

          Dispatcher.BeginInvoke(()=>
          (sender as RadMaskedTextInput).Focus());
      }
and it worked correctly. Could you please try it out and let us know if it fits well in your scenario.

Regards,
Petar Mladenov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
WILLIAM
Top achievements
Rank 1
answered on 25 Mar 2014, 05:23 PM
Unfortunately, that did not work either.  I'm able to set the focus on every other control on the view except this one.

But thank you for the suggestion!!
0
Petar Mladenov
Telerik team
answered on 28 Mar 2014, 08:40 AM
Hi William,

Please find the attached project in which the RadMaskedTextInput is focused initially. Is this the desired behavior you need ?

Regards,
Petar Mladenov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
WILLIAM
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
WILLIAM
Top achievements
Rank 1
Share this question
or