public static TextBox FindNextTextBox(DependencyObject parent, TextBox textbox) { List <TextBox> textBoxList = FramePageUtils.AllTextBoxes(parent); int num = textBoxList.IndexOf(textbox); if (num >= 0 && num < textBoxList.Count - 1) { return(textBoxList[num + 1]); } return(null); }
public static List <TextBox> AllTextBoxes(DependencyObject parent) { List <TextBox> textBoxList = new List <TextBox>(); for (int index = 0; index < VisualTreeHelper.GetChildrenCount(parent); ++index) { DependencyObject child = VisualTreeHelper.GetChild(parent, index); if (child is TextBox) { textBoxList.Add(child as TextBox); } textBoxList.AddRange((IEnumerable <TextBox>)FramePageUtils.AllTextBoxes(child)); } return(textBoxList); }