better counter logic
MODIFY
WalletWasabi.Fluent/Controls/TagControl.axaml
WalletWasabi.Fluent/Controls/TagControl.axaml
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:c="using:WalletWasabi.Fluent.Controls">
+ xmlns:c="using:WalletWasabi.Fluent.Controls"
+ xmlns:converters="clr-namespace:WalletWasabi.Fluent.Converters">
<Design.PreviewWith>
<Border Padding="10">
<c:TagControl Content="Test" />
</LayoutTransformControl.Transitions>
</LayoutTransformControl>
<StackPanel Margin="12,6,12,6" DockPanel.Dock="Left" Spacing="5" Orientation="Horizontal">
- <TextBlock Name="PART_Index" IsVisible="{TemplateBinding EnableCounter}"/>
+ <TextBlock Text="{TemplateBinding OrdinalIndex, Converter={x:Static converters:IntConverter.ToOrdinalString}}" IsVisible="{TemplateBinding EnableCounter}"/>
<ContentPresenter Name="PART_ContentPresenter"
Content="{TemplateBinding Content}"
Padding="{TemplateBinding Padding}"

MODIFY
WalletWasabi.Fluent/Controls/TagControl.axaml.cs
WalletWasabi.Fluent/Controls/TagControl.axaml.cs
@@ -19,6 +19,9 @@ namespace WalletWasabi.Fluent.Controls
public static readonly StyledProperty<bool> EnableDeleteProperty =
AvaloniaProperty.Register<TagControl, bool>(nameof(EnableDelete));
+ public static readonly StyledProperty<int> OrdinalIndexProperty =
+ AvaloniaProperty.Register<TagControl, int>(nameof(OrdinalIndex));
+
public bool EnableCounter
{
get => GetValue(EnableCounterProperty);
@@ -31,6 +34,12 @@ namespace WalletWasabi.Fluent.Controls
set => SetValue(EnableDeleteProperty, value);
}
+ public int OrdinalIndex
+ {
+ get => GetValue(OrdinalIndexProperty);
+ set => SetValue(OrdinalIndexProperty, value);
+ }
+
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);

MODIFY
WalletWasabi.Fluent/Controls/TagsBox.axaml.cs
WalletWasabi.Fluent/Controls/TagsBox.axaml.cs
@@ -228,10 +228,7 @@ namespace WalletWasabi.Fluent.Controls
for (var i = 0; i < tagItems.Length; i++)
{
- if (tagItems[i].FindDescendantOfType<TextBlock>() is { } textBlock)
- {
- textBlock.Text = $"{i + 1}.";
- }
+ tagItems[i].OrdinalIndex = i + 1;
}
}
}

ADD
WalletWasabi.Fluent/Converters/IntConverter.cs
+using Avalonia.Data.Converters;
+
+namespace WalletWasabi.Fluent.Converters
+{
+ public static class IntConverter
+ {
+ public static readonly IValueConverter ToOrdinalString =
+ new FuncValueConverter<int, string>(x => $"{x}.");
+ }
+}

better counter logic