private void AddElseIfChildControl(EditableIfScript.EditableElseIf elseIfData) { IfEditorChild newChild = new IfEditorChild(); newChild.Mode = IfEditorChild.IfEditorChildMode.ElseIf; newChild.Margin = new Thickness(0, 10, 0, 0); newChild.Dirty += RaiseDirtyEvent; newChild.RequestParentElementEditorSave += RaiseRequestParentElementEditorSaveEvent; newChild.Delete += IfEditorChild_Delete; newChild.Initialise(m_controller); newChild.ReadOnly = m_readOnly; newChild.Populate(elseIfData, elseIfData.EditableScripts); newChild.ElseIfData = elseIfData; m_elseIfEditors.Add(elseIfData.Id, newChild); // First ElseIf script is at Row 1 int rowIndex = m_elseIfEditors.Count; if (m_elseIfEditors.Count > m_elseIfGridRows.Count) { RowDefinition newRow = new RowDefinition(); newRow.Height = GridLength.Auto; grid.RowDefinitions.Insert(rowIndex, newRow); m_elseIfGridRows.Add(newRow); Grid.SetRow(cmdAddElseIf, Grid.GetRow(cmdAddElseIf) + 1); Grid.SetRow(cmdAddElse, Grid.GetRow(cmdAddElse) + 1); Grid.SetRow(ctlElse, Grid.GetRow(ctlElse) + 1); } Grid.SetRow(newChild, rowIndex); grid.Children.Add(newChild); }