public void RemoveComponent(UXComponent component) { if (component != null) { // Try to find the component string key = componentDict[component]; if (!string.IsNullOrEmpty(key)) { if (cells[key].Component is UXContainer) { UXContainer cellContainer = cells[key].Component as UXContainer; cellContainer.Children.Remove(component); component.Parent = null; // Check if there is just one left in container then we need to remove the container. if (cellContainer.Children.Count == 1) { Children.Remove(cells[key].Component); cells[key].Component = cellContainer.Children[0]; Children.Add(cells[key].Component); } } else { cells.Remove(key); component.Parent = null; Children.Remove(component); } // Remove component from dictionary componentDict.Remove(component); } } }
public UXChildCollection(UXContainer container) { this.container = container; }
public UXLayoutGridCell AddComponent(int column, int row, int columnSpan, UXComponent newComponent) { string key = Key(column, row); if (!componentDict.ContainsKey(newComponent)) { if (cells.ContainsKey(key)) { componentDict.Add(newComponent, key); if (cells[key].Component is UXContainer) { UXContainer cellContainer = cells[key].Component as UXContainer; cellContainer.Children.Add(newComponent); newComponent.Parent = cellContainer; Children.Add(cellContainer); } else { // If more than one component in cell create stackpanel UXComponent orgCellComponent = cells[key].Component; UXStackPanel uxStackPanel = new UXStackPanel() { Parent = this, Orientation = UXPanelOrientation.Horizontal }; cells[key].Component = uxStackPanel; orgCellComponent.Parent = uxStackPanel; uxStackPanel.Children.Add(orgCellComponent); newComponent.Parent = uxStackPanel; uxStackPanel.Children.Add(newComponent); Children.Remove(orgCellComponent); Children.Add(uxStackPanel); } } else { UXLayoutGridCell cell = new UXLayoutGridCell() { Row = row, Column = column, Component = newComponent, ColumnSpan = columnSpan }; cells[key] = cell; Children.Add(newComponent); if (newComponent is UXContainer) { foreach (UXComponent comp in ((UXContainer)newComponent).Children) { componentDict.Add(comp, key); } } else { componentDict.Add(newComponent, key); } } } return(cells[key]); }