make focus onattached behavior a disposing behavior.
MODIFY
WalletWasabi.Fluent/Behaviors/AttachedToVisualTreeBehavior.cs
WalletWasabi.Fluent/Behaviors/AttachedToVisualTreeBehavior.cs
+using System.Reactive.Disposables;
using Avalonia;
using Avalonia.Xaml.Interactivity;
namespace WalletWasabi.Fluent.Behaviors
{
- public abstract class AttachedToVisualTreeBehavior<T> : Behavior<T> where T : Visual
+ public abstract class AttachedToVisualTreeBehavior<T> : DisposingBehavior<T> where T : Visual
{
- protected override void OnAttached()
+ private CompositeDisposable? _disposables;
+
+ protected override void OnAttached(CompositeDisposable disposables)
{
- base.OnAttached();
+ _disposables = disposables;
AssociatedObject!.AttachedToVisualTree += AssociatedObjectOnAttachedToVisualTree;
}
private void AssociatedObjectOnAttachedToVisualTree(object? sender, VisualTreeAttachmentEventArgs e)
{
- OnAttachedToVisualTree();
+ OnAttachedToVisualTree(_disposables!);
}
- protected abstract void OnAttachedToVisualTree();
+ protected abstract void OnAttachedToVisualTree(CompositeDisposable disposable);
protected override void OnDetaching()
{

MODIFY
WalletWasabi.Fluent/Behaviors/FocusOnAttachedBehavior.cs
WalletWasabi.Fluent/Behaviors/FocusOnAttachedBehavior.cs
+using System.Reactive.Disposables;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Threading;
@@ -15,7 +16,7 @@ namespace WalletWasabi.Fluent.Behaviors
set => SetValue(IsEnabledProperty, value);
}
- protected override void OnAttachedToVisualTree()
+ protected override void OnAttachedToVisualTree(CompositeDisposable disposables)
{
if (IsEnabled)
{

make focus onattached behavior a disposing behavior.