Use the owner constructor approach instead of the shell
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
@@ -60,7 +60,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
NotificationHelpers.Warning($"{nameof(KeyManager.MinGapLimit)} increased from {prevMinGapLimit} to {minGapLimit}.");
}
- var newAddress = new AddressViewModel(newKey, WalletService.KeyManager);
+ var newAddress = new AddressViewModel(newKey, WalletService.KeyManager, this);
Addresses.Insert(0, newAddress);
SelectedAddress = newAddress;
LabelSuggestion.Label = "";
@@ -92,7 +92,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public ReactiveCommand<Unit, Unit> GenerateCommand { get; }
- public WalletService WalletService { get; }
+ private WalletService WalletService { get; }
public SuggestLabelViewModel LabelSuggestion { get; }
@@ -130,7 +130,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
IEnumerable<HdPubKey> keys = WalletService.KeyManager.GetKeys(x => !x.Label.IsEmpty && !x.IsInternal && x.KeyState == KeyState.Clean).Reverse();
foreach (HdPubKey key in keys)
{
- _addresses.Add(new AddressViewModel(key, WalletService.KeyManager));
+ _addresses.Add(new AddressViewModel(key, WalletService.KeyManager, this));
}
}
catch (Exception ex)

MODIFY
WalletWasabi.Gui/ViewModels/AddressViewModel.cs
WalletWasabi.Gui/ViewModels/AddressViewModel.cs
using Avalonia;
-using AvalonStudio.Extensibility;
-using AvalonStudio.Shell;
using Gma.QrCodeNet.Encoding;
using ReactiveUI;
using Splat;
@@ -43,12 +41,14 @@ namespace WalletWasabi.Gui.ViewModels
public HdPubKey Model { get; }
private Global Global { get; }
public KeyManager KeyManager { get; }
+ public ReceiveTabViewModel Owner { get; }
public bool IsHardwareWallet { get; }
- public AddressViewModel(HdPubKey model, KeyManager km)
+ public AddressViewModel(HdPubKey model, KeyManager km, ReceiveTabViewModel owner)
{
Global = Locator.Current.GetService<Global>();
KeyManager = km;
+ Owner = owner;
IsHardwareWallet = km.IsHardwareWallet;
Model = model;
ClipboardNotificationVisible = false;
@@ -129,7 +129,7 @@ namespace WalletWasabi.Gui.ViewModels
LockAddress = ReactiveCommand.CreateFromTask(async () =>
{
Model.SetKeyState(KeyState.Locked, km);
- IoC.Get<IShell>().Documents?.OfType<ReceiveTabViewModel>()?.FirstOrDefault(x => x.WalletService.KeyManager == KeyManager).InitializeAddresses();
+ owner.InitializeAddresses();
bool isAddressCopied = await Application.Current.Clipboard.GetTextAsync() == Address;
if (isAddressCopied)

Use the owner constructor approach instead of the shell