Use Application.Current.Clipboard everywhere.
MODIFY
WalletWasabi.Gui/Behaviors/PasteAddressOnClickBehavior.cs
WalletWasabi.Gui/Behaviors/PasteAddressOnClickBehavior.cs
@@ -61,9 +61,7 @@ namespace WalletWasabi.Gui.Behaviors
public async Task<(bool isAddress, string address)> IsThereABitcoinAddressOnTheClipboardAsync()
{
- var clipboard = (IClipboard)AvaloniaLocator.Current.GetService(typeof(IClipboard));
- Task<string> clipboardTask = clipboard.GetTextAsync();
- string text = await clipboardTask;
+ string text = await Application.Current.Clipboard.GetTextAsync();
if (string.IsNullOrEmpty(text) || text.Length > 100)
{
return (false, null);

MODIFY
WalletWasabi.Gui/Controls/ExtendedTextBox.cs
WalletWasabi.Gui/Controls/ExtendedTextBox.cs
@@ -68,7 +68,7 @@ namespace WalletWasabi.Gui.Controls
private async Task PasteAsync()
{
- var text = await ((IClipboard)AvaloniaLocator.Current.GetService(typeof(IClipboard))).GetTextAsync();
+ var text = await Application.Current.Clipboard.GetTextAsync();
if (text is null)
{
@@ -112,8 +112,7 @@ namespace WalletWasabi.Gui.Controls
if (!string.IsNullOrWhiteSpace(selection))
{
- await ((IClipboard)AvaloniaLocator.Current.GetService(typeof(IClipboard)))
- .SetTextAsync(selection);
+ await Application.Current.Clipboard.SetTextAsync(selection);
}
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
@@ -119,8 +119,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
try
{
- await ((IClipboard)AvaloniaLocator.Current.GetService(typeof(IClipboard)))
- .SetTextAsync(SelectedAddress.Label ?? string.Empty);
+ await Application.Current.Clipboard.SetTextAsync(SelectedAddress.Label ?? string.Empty);
}
catch (Exception)
{ }

Use Application.Current.Clipboard everywhere.