/// <summary> /// Gets the controls in pairs. /// </summary> /// <returns>List<ControlPair>.</returns> private List <ControlPair> GetControls() { var controls = new List <ControlPair>(); for (var controlCounter = 0; controlCounter < Children.Count; controlCounter++) { var child = Children[controlCounter]; if (child.Visibility == Visibility.Collapsed) { continue; } var controlPair = new ControlPair(0d); if (SimpleView.GetIsStandAloneEditControl(child)) { controlPair.Edit = child; } else { controlPair.Label = child; if (SimpleView.GetSpanFullWidth(child)) { controlPair.LabelSpansFullWidth = true; } else if (!SimpleView.GetIsStandAloneLabel(child)) { var editControlIndex = controlCounter + 1; if (Children.Count > editControlIndex) { controlPair.Edit = Children[editControlIndex]; } controlCounter++; // We are skipping the next control since we already accounted for it while (true) // We check if the next control might flow with the current edit control { if (Children.Count <= controlCounter + 1) { break; } if (!SimpleView.GetFlowsWithPrevious(Children[controlCounter + 1])) { break; } controlPair.AdditionalEditControls.Add(Children[controlCounter + 1]); controlCounter++; } } } controls.Add(controlPair); } return(controls); }