using System.Reactive.Disposables; using Avalonia.Xaml.Interactivity; namespace Avalonia.Xaml.Interactions.Custom; /// /// A base class for behaviors using attached to logical tree event. /// /// public abstract class AttachedToLogicalTreeBehavior : DisposingBehavior where T : StyledElement { private CompositeDisposable? _disposables; /// protected override void OnAttached(CompositeDisposable disposables) { _disposables = disposables; } /// protected override void OnAttachedToLogicalTree() { OnAttachedToLogicalTree(_disposables!); } /// /// Called after the is attached to the logical tree. /// /// The group of disposable resources that are disposed together protected abstract void OnAttachedToLogicalTree(CompositeDisposable disposable); }