fix diposing of template subscriptions.
MODIFY
WalletWasabi.Fluent/Controls/TagsBox.xaml.cs
WalletWasabi.Fluent/Controls/TagsBox.xaml.cs
@@ -31,7 +31,7 @@ namespace WalletWasabi.Fluent.Controls
o => o.Suggestions,
(o, v) => o.Suggestions = v);
- private readonly CompositeDisposable _compositeDisposable = new CompositeDisposable();
+ private CompositeDisposable? _compositeDisposable;
private AutoCompleteBox? _autoCompleteBox;
@@ -77,6 +77,10 @@ namespace WalletWasabi.Fluent.Controls
Presenter.ApplyTemplate();
+ _compositeDisposable?.Dispose();
+
+ _compositeDisposable = new CompositeDisposable();
+
_autoCompleteBox = (Presenter.Panel as ConcatenatingWrapPanel)?.ConcatenatedChildren
.OfType<AutoCompleteBox>().FirstOrDefault();
@@ -89,6 +93,15 @@ namespace WalletWasabi.Fluent.Controls
_autoCompleteBox.TextChanged += OnTextChanged;
_autoCompleteBox.DropDownClosed += OnDropDownClosed;
+ Disposable.Create(
+ () =>
+ {
+ _autoCompleteBox.KeyUp -= OnKeyUp;
+ _autoCompleteBox.TextChanged -= OnTextChanged;
+ _autoCompleteBox.DropDownClosed -= OnDropDownClosed;
+ })
+ .DisposeWith(_compositeDisposable);
+
_autoCompleteBox
.AddDisposableHandler(TextInputEvent, OnTextInput, RoutingStrategies.Tunnel)
.DisposeWith(_compositeDisposable);
@@ -103,12 +116,6 @@ namespace WalletWasabi.Fluent.Controls
}
}
- protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
- {
- _compositeDisposable.Dispose();
- base.OnDetachedFromVisualTree(e);
- }
-
private void CheckIsInputEnabled()
{
if (Items is IList x &&

fix diposing of template subscriptions.