diff --git a/Directory.Packages.props b/Directory.Packages.props
index e6fd1aae..f8d7c852 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -14,7 +14,6 @@
-
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Animations/FadeInBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Animations/FadeInBehavior.cs
index e9d1a99d..a21f1d7a 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Animations/FadeInBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Animations/FadeInBehavior.cs
@@ -1,7 +1,6 @@
using System;
using Avalonia.Animation;
using Avalonia.Styling;
-using System.Reactive.Disposables;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -43,12 +42,11 @@ public TimeSpan Duration
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
if (AssociatedObject is null)
{
- return;
+ return DisposableAction.Empty;
}
var totalDuration = InitialDelay + Duration;
@@ -64,5 +62,7 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
}
};
animation.RunAsync(AssociatedObject);
+
+ return DisposableAction.Empty;
}
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Avalonia.Xaml.Interactions.Custom.csproj b/src/Avalonia.Xaml.Interactions.Custom/Avalonia.Xaml.Interactions.Custom.csproj
index 6a7e203e..845185c3 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Avalonia.Xaml.Interactions.Custom.csproj
+++ b/src/Avalonia.Xaml.Interactions.Custom/Avalonia.Xaml.Interactions.Custom.csproj
@@ -15,7 +15,6 @@
-
diff --git a/src/Avalonia.Xaml.Interactions.Custom/BindPointerOverBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/BindPointerOverBehavior.cs
index 587969de..760fea56 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/BindPointerOverBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/BindPointerOverBehavior.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Input;
@@ -28,21 +28,22 @@ public bool IsPointerOver
///
///
///
- ///
- protected override void OnAttached(CompositeDisposable disposables)
+ ///
+ protected override IDisposable OnAttachedOverride()
{
if (AssociatedObject is null)
{
- return;
+ return DisposableAction.Empty;
}
var control = AssociatedObject;
control.PropertyChanged += AssociatedObjectOnPropertyChanged;
- disposables.Add(Disposable.Create(() => control.PropertyChanged -= AssociatedObjectOnPropertyChanged));
- disposables.Add(Disposable.Create(() => IsPointerOver = false));
-
- return;
+ return DisposableAction.Create(() =>
+ {
+ control.PropertyChanged -= AssociatedObjectOnPropertyChanged;
+ IsPointerOver = false;
+ });
void AssociatedObjectOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
{
diff --git a/src/Avalonia.Xaml.Interactions.Custom/BindTagToVisualRootDataContextBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/BindTagToVisualRootDataContextBehavior.cs
index 52aea4f2..7cf4e63b 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/BindTagToVisualRootDataContextBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/BindTagToVisualRootDataContextBehavior.cs
@@ -1,5 +1,4 @@
using System;
-using System.Reactive.Disposables;
using Avalonia.Controls;
using Avalonia.VisualTree;
@@ -13,16 +12,17 @@ public class BindTagToVisualRootDataContextBehavior : DisposingBehavior
///
///
///
- ///
+ ///
///
- protected override void OnAttached(CompositeDisposable disposables)
+ protected override IDisposable OnAttachedOverride()
{
var visualRoot = (Control?)AssociatedObject?.GetVisualRoot();
if (visualRoot is not null)
{
- var disposable = BindDataContextToTag(visualRoot, AssociatedObject);
- disposables.Add(disposable);
+ return BindDataContextToTag(visualRoot, AssociatedObject);
}
+
+ return DisposableAction.Empty;
}
private static IDisposable BindDataContextToTag(Control source, Control? target)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/BoundsObserverBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/BoundsObserverBehavior.cs
index 7dab95d4..256190a2 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/BoundsObserverBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/BoundsObserverBehavior.cs
@@ -1,7 +1,7 @@
-using System.Reactive;
-using System.Reactive.Disposables;
+using System;
using Avalonia.Controls;
using Avalonia.Data;
+using Avalonia.Reactive;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -60,17 +60,19 @@ public double Height
///
/// Attaches the behavior to the associated control and starts observing its bounds to update the Width and Height properties accordingly.
///
- /// A composite disposable used to manage the lifecycle of subscriptions and other disposables.
- protected override void OnAttached(CompositeDisposable disposables)
+ /// A disposable resource to be disposed when the behavior is detached.
+ protected override IDisposable OnAttachedOverride()
{
if (AssociatedObject is not null)
{
- disposables.Add(this.GetObservable(BoundsProperty)
+ return this.GetObservable(BoundsProperty)
.Subscribe(new AnonymousObserver(bounds =>
{
Width = bounds.Width;
Height = bounds.Height;
- })));
+ }));
}
+
+ return DisposableAction.Empty;
}
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonExecuteCommandOnKeyDownBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonExecuteCommandOnKeyDownBehavior.cs
index fb63c2d1..509b828c 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonExecuteCommandOnKeyDownBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonExecuteCommandOnKeyDownBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -15,14 +14,15 @@ public class ButtonExecuteCommandOnKeyDownBehavior : ExecuteCommandOnKeyBehavior
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposables)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
if (AssociatedObject?.GetVisualRoot() is InputElement inputRoot)
{
- var disposable = inputRoot.AddDisposableHandler(InputElement.KeyDownEvent, RootDefaultKeyDown);
- disposables.Add(disposable);
+ return inputRoot.AddDisposableHandler(InputElement.KeyDownEvent, RootDefaultKeyDown);
}
+
+ return DisposableAction.Empty;
}
private void RootDefaultKeyDown(object? sender, KeyEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonHideFlyoutBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonHideFlyoutBehavior.cs
index a30d9a4b..2cbb3556 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonHideFlyoutBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonHideFlyoutBehavior.cs
@@ -1,6 +1,6 @@
using System;
-using System.Reactive.Disposables;
using Avalonia.Controls;
+using Avalonia.Reactive;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -27,18 +27,16 @@ public bool IsFlyoutOpen
///
///
///
- ///
- protected override void OnAttached(CompositeDisposable disposables)
+ ///
+ protected override IDisposable OnAttachedOverride()
{
- var disposable = this.GetObservable(IsFlyoutOpenProperty)
- .Subscribe(isOpen =>
+ return this.GetObservable(IsFlyoutOpenProperty)
+ .Subscribe(new AnonymousObserver(isOpen =>
{
if (!isOpen)
{
AssociatedObject?.Flyout?.Hide();
}
- });
-
- disposables.Add(disposable);
+ }));
}
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonHideFlyoutOnClickBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonHideFlyoutOnClickBehavior.cs
index 3535fb32..492e1475 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonHideFlyoutOnClickBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Button/ButtonHideFlyoutOnClickBehavior.cs
@@ -1,6 +1,4 @@
using System;
-using System.Reactive.Disposables;
-using System.Reactive.Linq;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;
@@ -16,33 +14,39 @@ public class ButtonHideFlyoutOnClickBehavior : AttachedToVisualTreeBehavior
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposables)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
- if (AssociatedObject is null)
+ var button = AssociatedObject;
+
+ if (button is null)
{
- return;
+ return DisposableAction.Empty;
}
- var flyoutPresenter = AssociatedObject.FindAncestorOfType();
+ var flyoutPresenter = button.FindAncestorOfType();
if (flyoutPresenter?.Parent is not Popup popup)
{
- return;
+ return DisposableAction.Empty;
}
- var disposable = Observable
- .FromEventPattern(handler => AssociatedObject.Click += handler, handler => AssociatedObject.Click -= handler)
- .Do(_ =>
- {
- // Execute Command if any before closing. Otherwise, it won't execute because Close will destroy the associated object before Click can execute it.
- if (AssociatedObject.Command != null && AssociatedObject.IsEnabled)
- {
- AssociatedObject.Command.Execute(AssociatedObject.CommandParameter);
- }
- popup.Close();
- })
- .Subscribe();
-
- disposables.Add(disposable);
+ button.Click += AssociatedObjectOnClick;
+
+ return DisposableAction.Create(() =>
+ {
+ button.Click -= AssociatedObjectOnClick;
+ });
+
+ void AssociatedObjectOnClick(object sender, RoutedEventArgs e)
+ {
+ // Execute Command if any before closing. Otherwise, it won't execute because Close will destroy the associated object before Click can execute it.
+ if (button.Command != null && button.IsEnabled)
+ {
+ button.Command.Execute(button.CommandParameter);
+ }
+ popup.Close();
+ }
}
+
+
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Core/AttachedToLogicalTreeBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Core/AttachedToLogicalTreeBehavior.cs
index 82f87ad2..4df6b10d 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Core/AttachedToLogicalTreeBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Core/AttachedToLogicalTreeBehavior.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Xaml.Interactivity;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -9,23 +9,28 @@ namespace Avalonia.Xaml.Interactions.Custom;
///
public abstract class AttachedToLogicalTreeBehavior : DisposingBehavior where T : StyledElement
{
- private CompositeDisposable? _disposables;
+ private IDisposable? _disposable;
///
- protected override void OnAttached(CompositeDisposable disposables)
+ protected override IDisposable OnAttachedOverride()
{
- _disposables = disposables;
+ return new DisposableAction(OnDelayedDispose);
}
///
protected override void OnAttachedToLogicalTree()
{
- OnAttachedToLogicalTree(_disposables!);
+ _disposable = OnAttachedToLogicalTreeOverride();
}
///
/// Called after the is attached to the logical tree.
///
- /// The group of disposable resources that are disposed together
- protected abstract void OnAttachedToLogicalTree(CompositeDisposable disposable);
+ /// A disposable resource to be disposed when the behavior is detached.
+ protected abstract IDisposable OnAttachedToLogicalTreeOverride();
+
+ private void OnDelayedDispose()
+ {
+ _disposable?.Dispose();
+ }
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Core/AttachedToVisualTreeBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Core/AttachedToVisualTreeBehavior.cs
index 48be0ee0..4a04ef06 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Core/AttachedToVisualTreeBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Core/AttachedToVisualTreeBehavior.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Xaml.Interactivity;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -9,23 +9,28 @@ namespace Avalonia.Xaml.Interactions.Custom;
///
public abstract class AttachedToVisualTreeBehavior : DisposingBehavior where T : Visual
{
- private CompositeDisposable? _disposables;
+ private IDisposable? _disposable;
///
- protected override void OnAttached(CompositeDisposable disposables)
+ protected override IDisposable OnAttachedOverride()
{
- _disposables = disposables;
+ return new DisposableAction(OnDelayedDispose);
}
///
protected override void OnAttachedToVisualTree()
{
- OnAttachedToVisualTree(_disposables!);
+ _disposable = OnAttachedToVisualTreeOverride();
}
///
/// Called after the is attached to the visual tree.
///
- /// The group of disposable resources that are disposed together
- protected abstract void OnAttachedToVisualTree(CompositeDisposable disposable);
+ /// A disposable resource to be disposed when the behavior is detached.
+ protected abstract IDisposable OnAttachedToVisualTreeOverride();
+
+ private void OnDelayedDispose()
+ {
+ _disposable?.Dispose();
+ }
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Core/BindingBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Core/BindingBehavior.cs
index 26326e21..d92c4a67 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Core/BindingBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Core/BindingBehavior.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Controls;
using Avalonia.Data;
@@ -59,13 +59,14 @@ public IBinding? Binding
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
if (TargetObject is not null && TargetProperty is not null && Binding is not null)
{
- var dispose = TargetObject.Bind(TargetProperty, Binding);
- disposable.Add(dispose);
+ return TargetObject.Bind(TargetProperty, Binding);
}
+
+ return DisposableAction.Empty;
}
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Core/DisposableAction.cs b/src/Avalonia.Xaml.Interactions.Custom/Core/DisposableAction.cs
new file mode 100644
index 00000000..f8fcaf48
--- /dev/null
+++ b/src/Avalonia.Xaml.Interactions.Custom/Core/DisposableAction.cs
@@ -0,0 +1,27 @@
+
+namespace Avalonia.Xaml.Interactions.Custom;
+///
+/// Represents an that executes a specified action when disposed.
+///
+/// The action to execute when disposed.
+public class DisposableAction(System.Action dispose) : System.IDisposable
+{
+ ///
+ /// An empty disposable that does nothing when disposed.
+ ///
+ // ReSharper disable once InconsistentNaming
+ public static readonly System.IDisposable Empty = new DisposableAction(() => { });
+
+ ///
+ /// Creates a new that executes the specified action when disposed.
+ ///
+ /// The action to execute when disposed.
+ /// A new instance of .
+ public static System.IDisposable Create(System.Action dispose)
+ => new DisposableAction(dispose);
+
+ ///
+ /// Executes the dispose action.
+ ///
+ void System.IDisposable.Dispose() => dispose();
+}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Core/DisposingBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Core/DisposingBehavior.cs
index d8e9ec4e..e71acdf7 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Core/DisposingBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Core/DisposingBehavior.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Xaml.Interactivity;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -9,31 +9,28 @@ namespace Avalonia.Xaml.Interactions.Custom;
/// The object type to attach to
public abstract class DisposingBehavior : StyledElementBehavior where T : AvaloniaObject
{
- private CompositeDisposable? _disposables;
+ private IDisposable? _disposable;
///
protected override void OnAttached()
{
base.OnAttached();
- _disposables?.Dispose();
-
- _disposables = new CompositeDisposable();
-
- OnAttached(_disposables);
+ _disposable?.Dispose();
+ _disposable = OnAttachedOverride();
}
///
/// Called after the behavior is attached to the .
///
- /// The group of disposable resources that are disposed together.
- protected abstract void OnAttached(CompositeDisposable disposables);
+ /// A disposable resource to be disposed when the behavior is detached.
+ protected abstract IDisposable OnAttachedOverride();
///
protected override void OnDetaching()
{
base.OnDetaching();
- _disposables?.Dispose();
+ _disposable?.Dispose();
}
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Core/DisposingTrigger.cs b/src/Avalonia.Xaml.Interactions.Custom/Core/DisposingTrigger.cs
index 33f43610..b513ab0a 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Core/DisposingTrigger.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Core/DisposingTrigger.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Xaml.Interactivity;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -8,7 +8,7 @@ namespace Avalonia.Xaml.Interactions.Custom;
///
public abstract class DisposingTrigger : StyledElementTrigger
{
- private readonly CompositeDisposable _disposables = new();
+ private IDisposable? _disposable;
///
///
@@ -17,14 +17,15 @@ protected override void OnAttached()
{
base.OnAttached();
- OnAttached(_disposables);
+ _disposable?.Dispose();
+ _disposable = OnAttachedOverride();
}
///
///
///
- ///
- protected abstract void OnAttached(CompositeDisposable disposables);
+ /// A disposable resource to be disposed when the behavior is detached.
+ protected abstract IDisposable OnAttachedOverride();
///
///
@@ -33,6 +34,6 @@ protected override void OnDetaching()
{
base.OnDetaching();
- _disposables.Dispose();
+ _disposable?.Dispose();
}
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Core/KeyDownTrigger.cs b/src/Avalonia.Xaml.Interactions.Custom/Core/KeyDownTrigger.cs
index 289a22b9..0ff6d1bf 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Core/KeyDownTrigger.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Core/KeyDownTrigger.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Xaml.Interactivity;
@@ -33,14 +33,15 @@ public Key Key
///
///
///
- ///
- protected override void OnAttached(CompositeDisposable disposables)
+ ///
+ protected override IDisposable OnAttachedOverride()
{
if (AssociatedObject is InputElement element)
{
- var disposable = element.AddDisposableHandler(InputElement.KeyDownEvent, OnKeyDown, EventRoutingStrategy);
- disposables.Add(disposable);
+ return element.AddDisposableHandler(InputElement.KeyDownEvent, OnKeyDown, EventRoutingStrategy);
}
+
+ return DisposableAction.Empty;
}
private void OnKeyDown(object? sender, KeyEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Core/LoadedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Core/LoadedBehavior.cs
index 92d92a9c..1065ea1a 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Core/LoadedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Core/LoadedBehavior.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Controls;
using Avalonia.Xaml.Interactivity;
@@ -10,23 +10,28 @@ namespace Avalonia.Xaml.Interactions.Custom;
///
public abstract class LoadedBehavior : DisposingBehavior where T : Control
{
- private CompositeDisposable? _disposables;
+ private IDisposable? _disposable;
///
- protected override void OnAttached(CompositeDisposable disposables)
+ protected override IDisposable OnAttachedOverride()
{
- _disposables = disposables;
+ return new DisposableAction(OnDelayedDispose);
}
///
protected override void OnLoaded()
{
- OnLoaded(_disposables!);
+ _disposable = OnLoadedOverride();
}
///
/// Called after the is loaded.
///
- /// The group of disposable resources that are disposed together
- protected abstract void OnLoaded(CompositeDisposable disposable);
+ /// A disposable resource to be disposed when the behavior is detached.
+ protected abstract IDisposable OnLoadedOverride();
+
+ private void OnDelayedDispose()
+ {
+ _disposable?.Dispose();
+ }
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnActivatedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnActivatedBehavior.cs
index 699ac8f6..f4501f73 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnActivatedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnActivatedBehavior.cs
@@ -1,5 +1,4 @@
using System;
-using System.Reactive.Disposables;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
@@ -13,8 +12,8 @@ public class ExecuteCommandOnActivatedBehavior : ExecuteCommandBehaviorBase
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime)
{
@@ -23,9 +22,11 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (mainWindow is not null)
{
mainWindow.Activated += WindowOnActivated;
- disposable.Add(Disposable.Create(() => mainWindow.Activated -= WindowOnActivated));
+ return DisposableAction.Create(() => mainWindow.Activated -= WindowOnActivated);
}
}
+
+ return DisposableAction.Empty;
}
private void WindowOnActivated(object? sender, EventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnDoubleTappedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnDoubleTappedBehavior.cs
index 13bdda7a..0d2cebda 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnDoubleTappedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnDoubleTappedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnDoubleTappedBehavior : ExecuteCommandRoutedEventBeh
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnDoubleTapped(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnGotFocusBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnGotFocusBehavior.cs
index 761e28a9..09216cb7 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnGotFocusBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnGotFocusBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -19,8 +18,8 @@ static ExecuteCommandOnGotFocusBehavior()
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -31,8 +30,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnGotFocus(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnHoldingBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnHoldingBehavior.cs
index 3cddd342..49760116 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnHoldingBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnHoldingBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnHoldingBehavior : ExecuteCommandRoutedEventBehavior
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnHolding(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnKeyDownBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnKeyDownBehavior.cs
index 89957a80..36f42cdf 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnKeyDownBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnKeyDownBehavior.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +12,8 @@ public class ExecuteCommandOnKeyDownBehavior : ExecuteCommandOnKeyBehaviorBase
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +24,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnKeyDown(object? sender, KeyEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnKeyUpBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnKeyUpBehavior.cs
index d05ba2a9..4cea247d 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnKeyUpBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnKeyUpBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnKeyUpBehavior : ExecuteCommandOnKeyBehaviorBase
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnKeyUp(object? sender, KeyEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnLostFocusBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnLostFocusBehavior.cs
index f052c602..5ca8bbfa 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnLostFocusBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnLostFocusBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -19,8 +18,8 @@ static ExecuteCommandOnLostFocusBehavior()
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -31,8 +30,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnLostFocus(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPinchBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPinchBehavior.cs
index 10cddb3b..8d85adb9 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPinchBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPinchBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPinchBehavior : ExecuteCommandRoutedEventBehaviorBa
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPinch(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPinchEndedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPinchEndedBehavior.cs
index d986f5f8..fe6021c9 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPinchEndedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPinchEndedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPinchEndedBehavior : ExecuteCommandRoutedEventBehav
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPinchEnded(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerCaptureLostBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerCaptureLostBehavior.cs
index 3e7572d4..3a48b512 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerCaptureLostBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerCaptureLostBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPointerCaptureLostBehavior : ExecuteCommandRoutedEv
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPointerCaptureLost(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerEnteredBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerEnteredBehavior.cs
index f7616ba1..6ad2c0af 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerEnteredBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerEnteredBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPointerEnteredBehavior : ExecuteCommandRoutedEventB
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPointerEntered(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerExitedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerExitedBehavior.cs
index 69fa96c9..9dd0d8c4 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerExitedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerExitedBehavior.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +12,8 @@ public class ExecuteCommandOnPointerExitedBehavior : ExecuteCommandRoutedEventBe
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +24,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPointerExited(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerMovedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerMovedBehavior.cs
index d501f168..3a309b45 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerMovedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerMovedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPointerMovedBehavior : ExecuteCommandRoutedEventBeh
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPointerMoved(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerPressedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerPressedBehavior.cs
index 532eb73a..29b49e90 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerPressedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerPressedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPointerPressedBehavior : ExecuteCommandRoutedEventB
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPointerPressed(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerReleasedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerReleasedBehavior.cs
index 9c0d4d78..b850102c 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerReleasedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerReleasedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPointerReleasedBehavior : ExecuteCommandRoutedEvent
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPointerReleased(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureMagnifyBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureMagnifyBehavior.cs
index b3ac21e9..6c25cfd4 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureMagnifyBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureMagnifyBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPointerTouchPadGestureMagnifyBehavior : ExecuteComm
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPointerTouchPadGestureMagnify(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureRotateBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureRotateBehavior.cs
index 25793c3e..d46d32c2 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureRotateBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureRotateBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPointerTouchPadGestureRotateBehavior : ExecuteComma
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPointerTouchPadGestureRotate(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureSwipeBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureSwipeBehavior.cs
index dd4f3492..afc35c9f 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureSwipeBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerTouchPadGestureSwipeBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPointerTouchPadGestureSwipeBehavior : ExecuteComman
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPointerTouchPadGestureSwipe(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerWheelChangedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerWheelChangedBehavior.cs
index 8899b58b..1e05bd2b 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerWheelChangedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPointerWheelChangedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPointerWheelChangedBehavior : ExecuteCommandRoutedE
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPointerWheelChanged(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPullGestureBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPullGestureBehavior.cs
index d889c9b4..5cab58be 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPullGestureBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPullGestureBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPullGestureBehavior : ExecuteCommandRoutedEventBeha
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPullGesture(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPullGestureEndedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPullGestureEndedBehavior.cs
index 5ee64178..74031457 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPullGestureEndedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnPullGestureEndedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnPullGestureEndedBehavior : ExecuteCommandRoutedEven
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnPullGestureEnded(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnRightTappedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnRightTappedBehavior.cs
index 4d8233c9..02139ba9 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnRightTappedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnRightTappedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnRightTappedBehavior : ExecuteCommandRoutedEventBeha
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnRightTapped(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureBehavior.cs
index 620a5f4b..24c0c03d 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnScrollGestureBehavior : ExecuteCommandRoutedEventBe
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnScrollGesture(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureEndedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureEndedBehavior.cs
index 9bd4f848..20f7fdc1 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureEndedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureEndedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnScrollGestureEndedBehavior : ExecuteCommandRoutedEv
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnScrollGestureEnded(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureInertiaStartingBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureInertiaStartingBehavior.cs
index 35d8f8d8..e6cb5d2f 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureInertiaStartingBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnScrollGestureInertiaStartingBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnScrollGestureInertiaStartingBehavior : ExecuteComma
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnScrollGestureInertiaStarting(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTappedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTappedBehavior.cs
index 95e34e4f..7c74209c 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTappedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTappedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnTappedBehavior : ExecuteCommandRoutedEventBehaviorB
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnTapped(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTextInputBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTextInputBehavior.cs
index d65e430a..4cbf44ce 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTextInputBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTextInputBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnTextInputBehavior : ExecuteCommandRoutedEventBehavi
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnTextInput(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTextInputMethodClientRequestedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTextInputMethodClientRequestedBehavior.cs
index a646321e..2bd5f490 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTextInputMethodClientRequestedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ExecuteCommand/ExecuteCommandOnTextInputMethodClientRequestedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ExecuteCommandOnTextInputMethodClientRequestedBehavior : ExecuteCom
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var control = SourceControl ?? AssociatedObject;
var dispose = control?
@@ -24,8 +23,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void OnTextInputMethodClientRequested(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusBehavior.cs
index bde09aef..1857a843 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusBehavior.cs
@@ -1,7 +1,6 @@
-using System.Reactive;
-using System.Reactive.Disposables;
using Avalonia.Controls;
using Avalonia.Data;
+using Avalonia.Reactive;
using Avalonia.Threading;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -29,30 +28,38 @@ public bool IsFocused
///
///
///
- ///
- protected override void OnAttached(CompositeDisposable disposables)
+ ///
+ protected override System.IDisposable OnAttachedOverride()
{
- if (AssociatedObject is not null)
- {
- disposables.Add(AssociatedObject.GetObservable(Avalonia.Input.InputElement.IsFocusedProperty)
- .Subscribe(new AnonymousObserver(
- focused =>
- {
- if (!focused)
- {
- SetCurrentValue(IsFocusedProperty, false);
- }
- })));
+ if (AssociatedObject is null)
+ {
+ return DisposableAction.Empty;
+ }
- disposables.Add(this.GetObservable(IsFocusedProperty)
- .Subscribe(new AnonymousObserver(
- focused =>
- {
- if (focused)
- {
- Dispatcher.UIThread.Post(() => AssociatedObject?.Focus());
- }
- })));
- }
+ var associatedObjectIsFocusedObservableDispose = AssociatedObject.GetObservable(Avalonia.Input.InputElement.IsFocusedProperty)
+ .Subscribe(new AnonymousObserver(
+ focused =>
+ {
+ if (!focused)
+ {
+ SetCurrentValue(IsFocusedProperty, false);
+ }
+ }));
+
+ var isFocusedObservableDispose = this.GetObservable(IsFocusedProperty)
+ .Subscribe(new AnonymousObserver(
+ focused =>
+ {
+ if (focused)
+ {
+ Dispatcher.UIThread.Post(() => AssociatedObject?.Focus());
+ }
+ }));
+
+ return DisposableAction.Create(() =>
+ {
+ associatedObjectIsFocusedObservableDispose.Dispose();
+ isFocusedObservableDispose.Dispose();
+ });
}
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusControlBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusControlBehavior.cs
index 31107562..f36fcf42 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusControlBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusControlBehavior.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Controls;
using Avalonia.Reactive;
using Avalonia.Threading;
@@ -28,12 +28,10 @@ public bool FocusFlag
///
///
///
- ///
- protected override void OnAttached(CompositeDisposable disposables)
+ ///
+ protected override IDisposable OnAttachedOverride()
{
- base.OnAttached(disposables);
-
- var disposable = this.GetObservable(FocusFlagProperty)
+ return this.GetObservable(FocusFlagProperty)
.Subscribe(new AnonymousObserver(
focusFlag =>
{
@@ -42,19 +40,18 @@ protected override void OnAttached(CompositeDisposable disposables)
Dispatcher.UIThread.Post(() => AssociatedObject?.Focus());
}
}));
-
- disposables.Add(disposable);
}
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
if (FocusFlag && IsEnabled)
{
Dispatcher.UIThread.Post(() => AssociatedObject?.Focus());
}
+
+ return DisposableAction.Empty;
}
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusOnAttachedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusOnAttachedBehavior.cs
index c684fb80..cf5f0222 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusOnAttachedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusOnAttachedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -10,9 +9,11 @@ public class FocusOnAttachedBehavior : FocusBehaviorBase
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposables)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
Focus();
+
+ return DisposableAction.Empty;
}
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusSelectedItemBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusSelectedItemBehavior.cs
index b8066a27..1e92b33b 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusSelectedItemBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Focus/FocusSelectedItemBehavior.cs
@@ -1,7 +1,6 @@
-using System;
-using System.Reactive.Disposables;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
+using Avalonia.Reactive;
using Avalonia.Threading;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -14,30 +13,33 @@ public class FocusSelectedItemBehavior : AttachedToVisualTreeBehavior
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var dispose = AssociatedObject?
.GetObservable(SelectingItemsControl.SelectedItemProperty)
- .Subscribe(selectedItem =>
- {
- var item = selectedItem;
- if (item is not null)
+ .Subscribe(new AnonymousObserver
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
AssociatedObject?.SelectAll();
+
+ return DisposableAction.Empty;
}
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/ListBox/ListBoxUnselectAllBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/ListBox/ListBoxUnselectAllBehavior.cs
index a3cd0c47..04931738 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/ListBox/ListBoxUnselectAllBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/ListBox/ListBoxUnselectAllBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Controls;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -11,9 +10,11 @@ public class ListBoxUnselectAllBehavior : AttachedToVisualTreeBehavior
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
AssociatedObject?.UnselectAll();
+
+ return DisposableAction.Empty;
}
}
diff --git a/src/Avalonia.Xaml.Interactions.Custom/SelectingItemsControl/SelectingItemsControlEventsBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/SelectingItemsControl/SelectingItemsControlEventsBehavior.cs
index 8a4e8031..12c52357 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/SelectingItemsControl/SelectingItemsControlEventsBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/SelectingItemsControl/SelectingItemsControlEventsBehavior.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
@@ -10,18 +10,17 @@ namespace Avalonia.Xaml.Interactions.Custom;
public abstract class SelectingItemsControlEventsBehavior : DisposingBehavior
{
///
- protected override void OnAttached(CompositeDisposable disposables)
+ protected override IDisposable OnAttachedOverride()
{
if (AssociatedObject is not { } selectingItemsControl)
{
- return;
+ return DisposableAction.Empty;
}
selectingItemsControl.SelectionChanged += SelectingItemsControlOnSelectionChanged;
- disposables.Add(
- Disposable.Create(
- () => selectingItemsControl.SelectionChanged -= SelectingItemsControlOnSelectionChanged));
+ return DisposableAction.Create(
+ () => selectingItemsControl.SelectionChanged -= SelectingItemsControlOnSelectionChanged);
}
private void SelectingItemsControlOnSelectionChanged(object sender, SelectionChangedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnDoubleTappedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnDoubleTappedBehavior.cs
index faa2081c..99671c49 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnDoubleTappedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnDoubleTappedBehavior.cs
@@ -1,5 +1,4 @@
-using System.Reactive.Disposables;
-using Avalonia.Input;
+using Avalonia.Input;
using Avalonia.Interactivity;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -12,8 +11,8 @@ public class ShowOnDoubleTappedBehavior : ShowBehaviorBase
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var dispose = AssociatedObject?
.AddDisposableHandler(
@@ -23,8 +22,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void AssociatedObject_DoubleTapped(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnKeyDownBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnKeyDownBehavior.cs
index 4023b29f..6635f222 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnKeyDownBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnKeyDownBehavior.cs
@@ -1,5 +1,4 @@
-using System.Reactive.Disposables;
-using Avalonia.Input;
+using Avalonia.Input;
using Avalonia.Interactivity;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -42,8 +41,8 @@ public KeyGesture? Gesture
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var dispose = AssociatedObject?
.AddDisposableHandler(
@@ -53,8 +52,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void AssociatedObject_KeyDown(object? sender, KeyEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnTappedBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnTappedBehavior.cs
index b8292e1b..4f33bd61 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnTappedBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/Show/ShowOnTappedBehavior.cs
@@ -1,4 +1,3 @@
-using System.Reactive.Disposables;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -12,8 +11,8 @@ public class ShowOnTappedBehavior : ShowBehaviorBase
///
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ ///
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
var dispose = AssociatedObject?
.AddDisposableHandler(
@@ -23,8 +22,10 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
if (dispose is not null)
{
- disposable.Add(dispose);
+ return dispose;
}
+
+ return DisposableAction.Empty;
}
private void AssociatedObject_Tapped(object? sender, RoutedEventArgs e)
diff --git a/src/Avalonia.Xaml.Interactions.Custom/TextBox/TextBoxSelectAllTextBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/TextBox/TextBoxSelectAllTextBehavior.cs
index d4b9cfc9..61dd66ad 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/TextBox/TextBoxSelectAllTextBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/TextBox/TextBoxSelectAllTextBehavior.cs
@@ -1,4 +1,4 @@
-using System.Reactive.Disposables;
+using System;
using Avalonia.Controls;
namespace Avalonia.Xaml.Interactions.Custom;
@@ -11,9 +11,10 @@ public class TextBoxSelectAllTextBehavior : AttachedToVisualTreeBehavior
///
///
- ///
- protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ protected override System.IDisposable OnAttachedToVisualTreeOverride()
{
AssociatedObject?.SelectAll();
+
+ return DisposableAction.Empty;
}
}
diff --git a/src/Xaml.Interactions/Xaml.Interactions.csproj b/src/Xaml.Interactions/Xaml.Interactions.csproj
index b9b78429..cc3ecc50 100644
--- a/src/Xaml.Interactions/Xaml.Interactions.csproj
+++ b/src/Xaml.Interactions/Xaml.Interactions.csproj
@@ -17,7 +17,6 @@
-