RadMaskedTextInput.Focus()

4 posts, 0 answers
  1. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 20 Mar 2014 Link to this post

    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!
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 25 Mar 2014 Link to this post

    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.

     
  3. DevCraft banner
  4. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 25 Mar 2014 in reply to Petar Mladenov Link to this post

    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!!
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 28 Mar 2014 Link to this post

    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.

     
Back to Top