/// <summary> /// Requests that the visual children of the panel use another control as their logical /// parent. /// </summary> /// <param name="logicalParent"> /// The logical parent for the visual children of the panel. /// </param> /// <param name="children"> /// The <see cref="ILogical.LogicalChildren"/> collection to modify. /// </param> void IReparentingControl.ReparentLogicalChildren(ILogical logicalParent, IPerspexList<ILogical> children) { Contract.Requires<ArgumentNullException>(logicalParent != null); Contract.Requires<ArgumentNullException>(children != null); _childLogicalParent = logicalParent; RedirectLogicalChildren(children); foreach (var control in Children) { ((ISetLogicalParent)control).SetParent(null); ((ISetLogicalParent)control).SetParent((IControl)logicalParent); children.Add(control); } }
/// <summary> /// Requests that the visual children of the panel use another control as their logical /// parent. /// </summary> /// <param name="logicalParent"> /// The logical parent for the visual children of the panel. /// </param> /// <param name="children"> /// The <see cref="ILogical.LogicalChildren"/> collection to modify. /// </param> void IReparentingControl.ReparentLogicalChildren(ILogical logicalParent, IPerspexList <ILogical> children) { Contract.Requires <ArgumentNullException>(logicalParent != null); Contract.Requires <ArgumentNullException>(children != null); _childLogicalParent = logicalParent; RedirectLogicalChildren(children); foreach (var control in Children) { ((ISetLogicalParent)control).SetParent(null); ((ISetLogicalParent)control).SetParent((IControl)logicalParent); children.Add(control); } }
private static void UpdateLogicalChild( IPerspexList <ILogical> logicalChildren, object oldValue, object newValue) { if (oldValue != newValue) { var logical = oldValue as ILogical; if (logical != null) { logicalChildren.Remove(logical); } logical = newValue as ILogical; if (logical != null) { logicalChildren.Add(logical); } } }
private static void UpdateLogicalChild( IControl control, IPerspexList <ILogical> logicalChildren, object oldValue, object newValue) { if (oldValue != newValue) { var child = oldValue as IControl; if (child != null) { logicalChildren.Remove(child); } child = newValue as IControl; if (child != null) { child.SetValue(Control.TemplatedParentProperty, control.TemplatedParent); logicalChildren.Add(child); } } }
/// <summary> /// Makes the control use a different control's logical children as its own. /// </summary> /// <param name="collection">The logical children to use.</param> protected void RedirectLogicalChildren(IPerspexList <ILogical> collection) { _logicalChildren = collection; }