Convert tagsbox into templatedcontrol instead to enforce tags list as strings only.
MODIFY
WalletWasabi.Fluent/Controls/TagsBox.axaml
WalletWasabi.Fluent/Controls/TagsBox.axaml
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}" Focusable="False">
<ItemsPresenter Name="PART_ItemsPresenter"
- Items="{TemplateBinding Items}"
- ItemTemplate="{TemplateBinding ItemTemplate}">
-
+ Items="{TemplateBinding Items}">
<ItemsPresenter.ItemsPanel>
<ItemsPanelTemplate>
<c:ConcatenatingWrapPanel>
</c:ConcatenatingWrapPanel>
</ItemsPanelTemplate>
</ItemsPresenter.ItemsPanel>
+ <ItemsPresenter.ItemTemplate>
+ <DataTemplate x:DataType="x:String">
+ <c:TagControl Content="{Binding .}"/>
+ </DataTemplate>
+ </ItemsPresenter.ItemTemplate>
</ItemsPresenter>
</Border>
</DataValidationErrors>

MODIFY
WalletWasabi.Fluent/Controls/TagsBox.axaml.cs
WalletWasabi.Fluent/Controls/TagsBox.axaml.cs
@@ -8,15 +8,17 @@ using System.Windows.Input;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Generators;
+using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Interactivity;
+using Avalonia.Metadata;
using Avalonia.Threading;
namespace WalletWasabi.Fluent.Controls
{
- public class TagsBox : ItemsControl
+ public class TagsBox : TemplatedControl
{
public static readonly StyledProperty<bool> RestrictInputToSuggestionsProperty =
AvaloniaProperty.Register<TagsBox, bool>(nameof(RestrictInputToSuggestions));
@@ -30,6 +32,12 @@ namespace WalletWasabi.Fluent.Controls
public static readonly StyledProperty<char> TagSeparatorProperty =
AvaloniaProperty.Register<TagsBox, char>(nameof(TagSeparator), defaultValue: ' ');
+ public static readonly DirectProperty<TagsBox, IEnumerable<string>> ItemsProperty =
+ AvaloniaProperty.RegisterDirect<TagsBox, IEnumerable<string>>(nameof(Items),
+ o => o.Items,
+ (o, v) => o.Items = v,
+ enableDataValidation: true);
+
public static readonly DirectProperty<TagsBox, IEnumerable?> SuggestionsProperty =
AvaloniaProperty.RegisterDirect<TagsBox, IEnumerable?>(
nameof(Suggestions),
@@ -37,15 +45,14 @@ namespace WalletWasabi.Fluent.Controls
(o, v) => o.Suggestions = v);
private CompositeDisposable? _compositeDisposable;
-
private AutoCompleteBox? _autoCompleteBox;
-
private bool _backspaceEmptyField1;
private bool _backspaceEmptyField2;
private bool _isFocused;
private bool _isInputEnabled = true;
private IEnumerable? _suggestions;
private ICommand? _completedCommand;
+ private IEnumerable<string> _items;
public static readonly DirectProperty<TagsBox, ICommand?> CompletedCommandProperty =
AvaloniaProperty.RegisterDirect<TagsBox, ICommand?>(
@@ -56,10 +63,11 @@ namespace WalletWasabi.Fluent.Controls
public static readonly StyledProperty<bool> IsReadOnlyProperty =
AvaloniaProperty.Register<TagsBox, bool>("IsReadOnly");
- static TagsBox()
+ [Content]
+ public IEnumerable<string> Items
{
- ItemsProperty.OverrideMetadata<TagsBox>(
- new DirectPropertyMetadata<IEnumerable?>(enableDataValidation: true));
+ get => _items;
+ set => SetAndRaise(ItemsProperty, ref _items, value);
}
public bool RestrictInputToSuggestions
@@ -108,12 +116,14 @@ namespace WalletWasabi.Fluent.Controls
{
base.OnApplyTemplate(e);
- Presenter.ApplyTemplate();
-
_compositeDisposable?.Dispose();
_compositeDisposable = new CompositeDisposable();
+ var Presenter = e.NameScope.Find<ItemsPresenter>("PART_ItemsPresenter");
+
+ Presenter.ApplyTemplate();
+
_autoCompleteBox = (Presenter.Panel as ConcatenatingWrapPanel)?.ConcatenatedChildren
.OfType<AutoCompleteBox>().FirstOrDefault();
@@ -147,9 +157,6 @@ namespace WalletWasabi.Fluent.Controls
}
}
- protected override IItemContainerGenerator CreateItemContainerGenerator() =>
- new ItemContainerGenerator<TagControl>(this,ContentControl.ContentProperty,ContentControl.ContentTemplateProperty);
-
private void CheckIsInputEnabled()
{
if (Items is IList x && ItemCountLimit > 0)

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
@@ -137,7 +137,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
private Interaction<(KeyPath, int), (KeyPath?, int?)> AdvancedOptionsInteraction { get; }
- public ObservableCollection<RecoveryWordIndexed> Mnemonics { get; } = new();
+ public ObservableCollection<string> Mnemonics { get; } = new();
private void ValidateMnemonics(IValidationErrors errors)
{
@@ -151,7 +151,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
{
if (!string.IsNullOrWhiteSpace(tagString) && Mnemonics.Count + 1 <= 12)
{
- Mnemonics.Add(new RecoveryWordIndexed(Mnemonics.Count + 1, tagString));
+ Mnemonics.Add( tagString);
}
SelectedTag = string.Empty;

DELETE
WalletWasabi.Fluent/ViewModels/AddWallet/RecoveryWordIndexed.cs
-namespace WalletWasabi.Fluent.ViewModels.AddWallet
-{
- public readonly struct RecoveryWordIndexed
- {
- public RecoveryWordIndexed(int index, string word)
- {
- Index = index;
- Word = word;
- }
-
- public int Index { get; }
- public string Word { get; }
-
- public override string ToString()
- {
- return Word;
- }
- }
-}
\ No newline at end of file

Convert tagsbox into templatedcontrol instead to enforce tags list as strings only.