This question is locked. New answers and comments are not allowed.
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.
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.