new tagsbox control.
MODIFY
WalletWasabi.Fluent/Controls/TagsBox.xaml
WalletWasabi.Fluent/Controls/TagsBox.xaml
<Setter Property="FocusAdorner" Value="{x:Null}" />
<Setter Property="Template">
<ControlTemplate>
- <Border Background="{TemplateBinding Background}"
+ <Border x:Name="PART_Border" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<ItemsPanelTemplate>
<c:ConcatenatingWrapPanel>
<c:ConcatenatingWrapPanel.ConcatenatedChildren>
- <TextBox Text="test" />
+ <AutoCompleteBox x:Name="PART_AutoCompleteBox" Items="{Binding #PART_Border.TemplatedParent.Suggestions}" />
</c:ConcatenatingWrapPanel.ConcatenatedChildren>
</c:ConcatenatingWrapPanel>
</ItemsPanelTemplate>

MODIFY
WalletWasabi.Fluent/Controls/TagsBox.xaml.cs
WalletWasabi.Fluent/Controls/TagsBox.xaml.cs
+using System.Collections;
+using System.Linq;
using Avalonia.Controls;
+using Avalonia;
+using Avalonia.Controls.Primitives;
namespace WalletWasabi.Fluent.Controls
{
@@ -6,6 +10,28 @@ namespace WalletWasabi.Fluent.Controls
/// </summary>
public class TagsBox : ItemsControl
{
+ private IEnumerable _suggestionsEnumerable;
+ private AutoCompleteBox _autoCompleteBox;
+ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
+ {
+ base.OnApplyTemplate(e);
+
+ Presenter.ApplyTemplate();
+
+ _autoCompleteBox =(Presenter.Panel as ConcatenatingWrapPanel).ConcatenatedChildren.OfType<AutoCompleteBox>().FirstOrDefault();
+ }
+
+ public static readonly DirectProperty<TagsBox, IEnumerable> SuggestionsProperty =
+ AvaloniaProperty.RegisterDirect<TagsBox, IEnumerable>(
+ nameof(Suggestions),
+ o => o.Suggestions,
+ (o, v) => o.Suggestions = v);
+
+ public IEnumerable Suggestions
+ {
+ get => _suggestionsEnumerable;
+ set => SetAndRaise(SuggestionsProperty, ref _suggestionsEnumerable, value);
+ }
}
}
\ No newline at end of file

RENAME
WalletWasabi.Fluent/Behaviors/TagsBoxAutoCompleteBoxBehavior.cs
WalletWasabi.Fluent/Controls/TagsBoxAutoCompleteBoxBehavior.cs
@@ -9,7 +9,7 @@ using Avalonia.Interactivity;
using Avalonia.Threading;
using Avalonia.Xaml.Interactivity;
-namespace WalletWasabi.Fluent.Behaviors
+namespace WalletWasabi.Fluent.Controls
{
public class TagsBoxAutoCompleteBoxBehavior : Behavior<AutoCompleteBox>
{

MODIFY
WalletWasabi.Fluent/ViewModels/TagsBox/TagsBoxViewModel.cs
WalletWasabi.Fluent/ViewModels/TagsBox/TagsBoxViewModel.cs
@@ -20,7 +20,6 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
{
public class TagsBoxViewModel : ViewModelBase
{
- private readonly ReadOnlyObservableCollection<object> _combinedContent;
private IEnumerable _suggestions;
private ObservableCollection<TagViewModel> _tags;
@@ -36,14 +35,6 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
var list = new SourceList<object>();
list.Add(TagInput);
- Tags.ToObservableChangeSet()
- .Cast(x => x as object)
- .Or(list.Connect())
- .Sort(SortExpressionComparer<object>.Ascending(i => i == TagInput ? 1 : 0))
- .ObserveOn(RxApp.MainThreadScheduler)
- .Bind(out _combinedContent)
- .AsObservableList();
-
GrabFocusCommand = ReactiveCommand.Create((object x) =>
{
TagInput?.GrabFocusAction?.Invoke();
@@ -57,8 +48,6 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
AddTag("Test5");
}
- public ReadOnlyObservableCollection<object> CombinedContent => _combinedContent;
-
public TagInputViewModel TagInput { get; }
public bool RestrictInputToSuggestions

MODIFY
WalletWasabi.Fluent/Views/RecoveryPageView.axaml
WalletWasabi.Fluent/Views/RecoveryPageView.axaml
<c:TagsBox x:Name="seedTagsBox" Grid.Row="2"
DataContext="{Binding RecoveryWordsTagsBox}"
Items="{Binding Tags}"
+ Suggestions="{Binding Suggestions, Mode=TwoWay}"
MinHeight="60"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
</Grid>

MODIFY
WalletWasabi.Fluent/Views/TagsBox/TagInputView.xaml
WalletWasabi.Fluent/Views/TagsBox/TagInputView.xaml
xmlns:behaviors="clr-namespace:WalletWasabi.Fluent.Behaviors;assembly=WalletWasabi.Fluent"
x:Class="WalletWasabi.Fluent.Views.TagsBox.TagInputView">
<AutoCompleteBox x:DataType="vm:TagInputViewModel" IsTextCompletionEnabled="True" Items="{CompiledBinding Suggestions}">
- <i:Interaction.Behaviors>
- <behaviors:TagsBoxAutoCompleteBoxBehavior
- IsInputEnabled="{CompiledBinding IsInputEnabled}"
- RestrictInputToSuggestions="{CompiledBinding RestrictInputToSuggestions}"
- Suggestions="{CompiledBinding Suggestions}"
- GrabFocusAction="{CompiledBinding GrabFocusAction, Mode=OneWayToSource}"
- CommitTextAction="{CompiledBinding CommitTextAction}"
- BackspaceAndEmptyTextAction="{CompiledBinding BackspaceAndEmptyTextAction}" />
- </i:Interaction.Behaviors>
+
</AutoCompleteBox>
</UserControl>
\ No newline at end of file

new tagsbox control.