Use Buttons for clickable suggestions
MODIFY
WalletWasabi.Gui/Behaviors/MnemonicSuggestionBehavior.cs
WalletWasabi.Gui/Behaviors/MnemonicSuggestionBehavior.cs
@@ -12,10 +12,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<string[]> SuggestionItemsProperty =
+ AvaloniaProperty.Register<MnemonicSuggestionBehavior, string[]>(nameof(SuggestionItems), defaultBindingMode: Avalonia.Data.BindingMode.TwoWay);
- public string SuggestionItems
+ public string[] SuggestionItems
{
get => GetValue(SuggestionItemsProperty);
set => SetValue(SuggestionItemsProperty, value);
@@ -50,11 +50,10 @@ namespace WalletWasabi.Gui.Behaviors
var text = textBox.Text;
var enteredWordList = text.Split(' ', StringSplitOptions.RemoveEmptyEntries);
var lastWorld = enteredWordList.LastOrDefault();
- var suggestions = SuggestionItems.Split(" ", StringSplitOptions.RemoveEmptyEntries);
+ var suggestions = SuggestionItems;
if(suggestions.Length == 1)
{
textBox.Text = text.Substring(0, text.Length - lastWorld.Length) + suggestions[0] + " ";
- textBox.CaretIndex = textBox.Text.Length;
}
}
}

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletView.xaml
WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletView.xaml
<behaviors:MnemonicSuggestionBehavior SuggestionItems="{Binding Suggestions}" />
</i:Interaction.Behaviors>
</controls:ExtendedTextBox>
- <TextBlock Text="{Binding Suggestions}" FontWeight="Bold" />
+ <ItemsControl Items="{Binding Suggestions}">
+ <ItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <StackPanel Orientation ="Horizontal" Spacing="2"/>
+ </ItemsPanelTemplate>
+ </ItemsControl.ItemsPanel>
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <Button Focusable="False" Content="{Binding}" Command="{Binding $parent[ItemsControl].DataContext.OnAddWord}" CommandParameter="{Binding}" />
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
</StackPanel>
</Grid>
</controls:GroupBox>

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletViewModel.cs
@@ -20,7 +20,7 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
private string _walletName;
private bool _termsAccepted;
private string _validationMessage;
- private string _suggestions;
+ private string[] _suggestions;
public RecoverWalletViewModel(WalletManagerViewModel owner) : base("Recover Wallet")
{
@@ -91,7 +91,7 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
set { this.RaiseAndSetIfChanged(ref _mnemonicWords, value); }
}
- public string Suggestions
+ public string[] Suggestions
{
get { return _suggestions; }
set { this.RaiseAndSetIfChanged(ref _suggestions, value); }
@@ -153,12 +153,21 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
if (lastWorld.Length < 1)
{
- Suggestions = string.Empty;
+ Suggestions = new string[0];
return;
}
var suggestedWords = EnglishWords.Where(w => w.StartsWith(lastWorld));
- Suggestions = string.Join(" ", suggestedWords.ToArray());
+ Suggestions = suggestedWords.ToArray();
+ }
+
+ public void OnAddWord(string word)
+ {
+ string[] words = MnemonicWords.Split(' ', StringSplitOptions.RemoveEmptyEntries);
+ words[words.Length-1] = word;
+
+ Suggestions = new string[0];
+ MnemonicWords = string.Join(' ', words) + " ";
}
private static IEnumerable<string> EnglishWords = Wordlist.English.GetWords();

Use Buttons for clickable suggestions