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

PassWordBox.Focus() does not scroll the passwordbox into view

1 Answer 29 Views
PasswordBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Curtis
Top achievements
Rank 1
Curtis asked on 04 Dec 2014, 04:07 PM
I have a stackpanel with 2 RadTextBox and 2 RadPasswordBox in vertical position.

In the OnKeyDown event I "tab" to the next control in the stackpanel:

private void OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key != Key.Enter) return;
            var control = sender as Control;
            if (control != null) control.TabToNextControl((Panel)control.Parent, this);
        }

and the following code does the focusing of the next control:

public static void TabToNextControl(this Control control, Panel parentContainer, Page parentPage)
        {
            // First hide the virtual keyboard
            parentPage.Focus(); 

            // Add 1 to calculate the next tab index
            int nextTabIndex = control.TabIndex + 1;

            // Check the controls in the parentcontainer for the next tab index and focus that control
            foreach (var c in parentContainer.ChildrenOfType<Control>())
            {
                if (c.TabIndex.Equals(nextTabIndex))
                {
                    c.Focus();
                    break;
                }
            }
           
        }
    }

When I tab from radtextbox to next radtextbox it works and the newly focused control scrolls into view with the keyboard open. When i tab from the normal textbox to textbox or passwordbox it works also. But when I focus the radpasswordbox it get the focus (colored rectangel around it) but it is not scrolled into view like the other control. 

Could this be a little bug? Radtextbox is descendent of Textbox and Radpasswordbox is descendent of radcontrol. Could this cause it and how to solve it?

Thanx in advance for the answer.

1 Answer, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 09 Dec 2014, 12:09 PM
Hi,

Please refer to the following forum thread : http://www.telerik.com/forums/passwordbox-focus()-does-not-scroll-the-passwordbox-into-view.

Regards,
Ivaylo Gergov
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
PasswordBox
Asked by
Curtis
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Share this question
or