Follow MVVM pattern
MODIFY
WalletWasabi.Gui/Behaviors/MnemonicSuggestionBehavior.cs
WalletWasabi.Gui/Behaviors/MnemonicSuggestionBehavior.cs
@@ -2,9 +2,11 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Xaml.Interactivity;
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
+using WalletWasabi.Gui.Tabs.WalletManager;
namespace WalletWasabi.Gui.Behaviors
{
@@ -12,10 +14,10 @@ namespace WalletWasabi.Gui.Behaviors
{
private CompositeDisposable _disposables;
- private static readonly AvaloniaProperty<string[]> SuggestionItemsProperty =
- AvaloniaProperty.Register<MnemonicSuggestionBehavior, string[]>(nameof(SuggestionItems), defaultBindingMode: Avalonia.Data.BindingMode.TwoWay);
+ private static readonly AvaloniaProperty<IEnumerable<MnemonicViewModel>> SuggestionItemsProperty =
+ AvaloniaProperty.Register<MnemonicSuggestionBehavior, IEnumerable<MnemonicViewModel>>(nameof(SuggestionItems), defaultBindingMode: Avalonia.Data.BindingMode.TwoWay);
- public string[] SuggestionItems
+ public IEnumerable<MnemonicViewModel> SuggestionItems
{
get => GetValue(SuggestionItemsProperty);
set => SetValue(SuggestionItemsProperty, value);
@@ -51,9 +53,9 @@ namespace WalletWasabi.Gui.Behaviors
var enteredWordList = text.Split(' ', StringSplitOptions.RemoveEmptyEntries);
var lastWorld = enteredWordList.LastOrDefault();
var suggestions = SuggestionItems;
- if(suggestions.Length == 1)
+ if(suggestions.Count() == 1)
{
- textBox.Text = text.Substring(0, text.Length - lastWorld.Length) + suggestions[0] + " ";
+ suggestions.First().OnSelected();
}
}
}

ADD
WalletWasabi.Gui/Tabs/WalletManager/MnemonicViewModel.cs
+using ReactiveUI;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace WalletWasabi.Gui.Tabs.WalletManager
+{
+ internal class MnemonicViewModel
+ {
+ public string Word { get; }
+ public Action<string> OnSelection { get; }
+
+ public MnemonicViewModel(string word, Action<string> onSeleted)
+ {
+ Word = word;
+ OnSelection = onSeleted;
+ }
+
+ public void OnSelected()
+ {
+ OnSelection(Word);
+ }
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletView.xaml
WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletView.xaml
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
- <Button Focusable="False" Content="{Binding}" Command="{Binding $parent[ItemsControl].DataContext.OnAddWord}" CommandParameter="{Binding}" />
+ <Button Focusable="False" Content="{Binding Word}" Command="{Binding OnSelected}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

Follow MVVM pattern