/// <summary> /// Initializes a new instance of the <see cref="PanelContainerBase"/> class. /// </summary> /// <param name="another">Another <see cref="PanelContainerBase"/> instance to copy data from.</param> protected PanelContainerBase(PanelContainerBase another) { Header = (IPanelHeader)another.Header.Clone(); isSelected = another.isSelected; // Detach from parent panel // Parent = null; // Remove original subscribiters // Closing = null; // -= Closing; // Closed = null; // -= Closed; // Deep copy all childs var childsCopy = new ObservableCollection <IPanel>(); // Important: handler below must belong to "result" object and NOT to "this" object! // See defect #18. childsCopy.CollectionChanged += OnChildsChanged; foreach (IPanel child in another.childs) { var newChild = (IPanel)child.Clone(); childsCopy.Add(newChild); if (child == another.Active) { active = newChild; } } childs = childsCopy; }
/// <summary> /// Initializes a new instance of the <see cref="PanelContainerBase"/> class. /// </summary> /// <param name="another">Another <see cref="PanelContainerBase"/> instance to copy data from.</param> protected PanelContainerBase(PanelContainerBase another) { if (another.Header != null) { Header = (IPanelHeader)another.Header.Clone(); } // Deep copy all childs foreach (IPresenter child in another.Presenters) { if (child is IPanel) { Presenters.Add((IPanel)((IPanel)child).Clone()); } } }