observe window activated event instead of focus
RENAME
WalletWasabi.Fluent/Behaviors/ExecuteCommandOnFocusWithin.cs
WalletWasabi.Fluent/Behaviors/ExecuteCommandOnActivated.cs
@@ -4,14 +4,14 @@ using System.Reactive.Linq;
using System.Windows.Input;
using Avalonia;
using Avalonia.Controls;
-using ReactiveUI;
+using Avalonia.Controls.ApplicationLifetimes;
namespace WalletWasabi.Fluent.Behaviors
{
- public class ExecuteCommandOnFocusWithin : DisposingBehavior<Control>
+ public class ExecuteCommandOnActivated : DisposingBehavior<Control>
{
public static readonly StyledProperty<ICommand?> CommandProperty =
- AvaloniaProperty.Register<ExecuteCommandOnFocusWithin, ICommand?>(nameof(Command));
+ AvaloniaProperty.Register<ExecuteCommandOnActivated, ICommand?>(nameof(Command));
public ICommand? Command
{
@@ -21,8 +21,10 @@ namespace WalletWasabi.Fluent.Behaviors
protected override void OnAttached(CompositeDisposable disposables)
{
- AssociatedObject?.WhenAnyValue(x => x.IsKeyboardFocusWithin)
- .Where(x => x)
+ var mainWindow = ((IClassicDesktopStyleApplicationLifetime) Application.Current.ApplicationLifetime).MainWindow;
+
+ Observable
+ .FromEventPattern(mainWindow, nameof(mainWindow.Activated))
.Subscribe(_ =>
{
if (Command is { } cmd && cmd.CanExecute(default))

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive;
+using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
@@ -306,6 +307,8 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
PriorLabels = new ObservableCollection<string>(PriorLabels.Distinct());
+ RxApp.MainThreadScheduler.Schedule(async () => await OnAutoPasteAsync());
+
base.OnNavigatedTo(inHistory, disposables);
}
}

MODIFY
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
x:CompileBindings="True"
x:Class="WalletWasabi.Fluent.Views.Wallets.Send.SendView">
<i:Interaction.Behaviors>
- <behaviors:ExecuteCommandOnFocusWithin Command="{Binding AutoPasteCommand}" />
+ <behaviors:ExecuteCommandOnActivated Command="{Binding AutoPasteCommand}" />
</i:Interaction.Behaviors>
<c:ContentArea Title="Send" Caption=""
EnableBack="{Binding EnableBack}"

observe window activated event instead of focus