/// <summary> /// Called when the control is removed from a logical tree. /// </summary> /// <param name="e">The event args.</param> /// <remarks> /// It is vital that if you override this method you call the base implementation; /// failing to do so will cause numerous features to not work as expected. /// </remarks> protected virtual void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { if (Name != null) { _nameScope?.Unregister(Name); } _isAttachedToLogicalTree = false; _styleDetach.OnNext(Unit.Default); this.TemplatedParent = null; DetachedFromLogicalTree?.Invoke(this, e); foreach (var child in LogicalChildren.OfType <Control>()) { child.OnDetachedFromLogicalTree(e); } }
/// <summary> /// Sets the control's logical parent. /// </summary> /// <param name="parent">The parent.</param> void ISetLogicalParent.SetParent(ILogical parent) { var old = Parent; if (parent != old) { if (old != null && parent != null) { throw new InvalidOperationException("The Control already has a parent."); } if (_isAttachedToLogicalTree) { var oldRoot = FindStyleRoot(old); if (oldRoot == null) { throw new PerspexInternalException("Was attached to logical tree but cannot find root."); } var e = new LogicalTreeAttachmentEventArgs(oldRoot); OnDetachedFromLogicalTreeCore(e); } InheritanceParent = parent as PerspexObject; _parent = (IControl)parent; if (_parent is IStyleRoot || _parent?.IsAttachedToLogicalTree == true) { var newRoot = FindStyleRoot(this); if (newRoot == null) { throw new PerspexInternalException("Parent is atttached to logical tree but cannot find root."); } var e = new LogicalTreeAttachmentEventArgs(newRoot); OnAttachedToLogicalTreeCore(e); } RaisePropertyChanged(ParentProperty, old, _parent, BindingPriority.LocalValue); } }
/// <summary> /// Called when the control is added to a logical tree. /// </summary> /// <param name="e">The event args.</param> /// <remarks> /// It is vital that if you override this method you call the base implementation; /// failing to do so will cause numerous features to not work as expected. /// </remarks> protected virtual void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { if (_nameScope == null) { _nameScope = NameScope.GetNameScope(this) ?? ((Control)Parent)?._nameScope; } if (Name != null) { _nameScope?.Register(Name, this); } _isAttachedToLogicalTree = true; PerspexLocator.Current.GetService <IStyler>()?.ApplyStyles(this); AttachedToLogicalTree?.Invoke(this, e); foreach (var child in LogicalChildren.OfType <Control>()) { child.OnAttachedToLogicalTree(e); } }
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnDetachedFromLogicalTree(e); ItemContainerGenerator.Clear(); }
/// <inheritdoc/> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); _treeView = this.GetLogicalAncestors().OfType <TreeView>().FirstOrDefault(); }
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); InvalidateFormattedText(); }
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnDetachedFromLogicalTree(e); ItemContainerGenerator.Clear(); }
/// <inheritdoc/> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); _treeView = this.GetLogicalAncestors().OfType<TreeView>().FirstOrDefault(); }
/// <summary> /// Called when the control is removed from a rooted logical tree. /// </summary> /// <param name="e">The event args.</param> protected virtual void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { DetachedFromLogicalTree?.Invoke(this, e); }
/// <summary> /// Called when the control is added to a rooted logical tree. /// </summary> /// <param name="e">The event args.</param> protected virtual void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { AttachedToLogicalTree?.Invoke(this, e); }
/// <inheritdoc/> void ILogical.NotifyDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { this.OnDetachedFromLogicalTreeCore(e); }
/// <inheritdoc/> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); this.UpdateSelectionBoxItem(this.SelectedItem); }
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); InvalidateFormattedText(); }
/// <inheritdoc/> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); this.UpdateSelectionBoxItem(this.SelectedItem); }