make a placeholder control instead
MODIFY
WalletWasabi.Fluent/Behaviors/PlaceholderRowsCalculatorBehavior.cs
WalletWasabi.Fluent/Behaviors/PlaceholderRowsCalculatorBehavior.cs
@@ -16,29 +16,23 @@ public class PlaceholderRowsCalculatorBehavior : AttachedToVisualTreeBehavior<Da
return;
}
- Dispatcher.UIThread.Post(() =>
- {
- CalculateRows(AssociatedObject.Bounds.Height);
- }, DispatcherPriority.Loaded);
-
- AssociatedObject.WhenAnyValue(x => x.Bounds)
+ AssociatedObject.Parent.WhenAnyValue(x => x.Bounds)
.Select(x => x.Height)
- .Where(x => x > 0)
+ // .Where(x => x > 0)
.Subscribe(CalculateRows)
.DisposeWith(disposables);
}
private void CalculateRows(double height)
{
- var totalRows = (int) Math.Floor(Math.Max(3, (height / 42) ));
- var opacityList = new List<double>();
+ var totalRows = (int) Math.Floor(Math.Max(3, height / 42));
var deltaOpacity = 1d / totalRows;
- foreach (var mult in Enumerable.Range(1, totalRows).Reverse())
- {
- opacityList.Add(mult * deltaOpacity);
- }
-
- AssociatedObject.Items = opacityList;
+ AssociatedObject.Items =
+ Enumerable
+ .Range(1, totalRows)
+ .Reverse()
+ .Select(mult => mult * deltaOpacity)
+ .ToList();
}
}
\ No newline at end of file

ADD
WalletWasabi.Fluent/Controls/HistoryPlaceholderPanel.axaml
+<Styles xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:c="using:WalletWasabi.Fluent.Controls"
+ xmlns:system="clr-namespace:System;assembly=System.Runtime">
+
+ <Style Selector="c|HistoryPlaceholderPanel">
+ <Setter Property="Template">
+ <ControlTemplate>
+ <Panel>
+ <ItemsControl x:Name="PART_DummyRows" x:CompileBindings="False">
+ <ItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <StackPanel Orientation="Vertical" />
+ </ItemsPanelTemplate>
+ </ItemsControl.ItemsPanel>
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <Panel Height="{StaticResource HistoryTableRowHeight}">
+ <Border Opacity="{Binding .}"
+ Background="{DynamicResource SystemChromeGrayColor}"
+ Height="10"
+ CornerRadius="5" Margin="5 0" />
+ </Panel>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </Panel>
+ </ControlTemplate>
+ </Setter>
+ </Style>
+
+</Styles>
\ No newline at end of file

ADD
WalletWasabi.Fluent/Controls/HistoryPlaceholderPanel.axaml.cs
+using System.Diagnostics;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Input;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.Primitives;
+using Avalonia.Media;
+using ReactiveUI;
+
+namespace WalletWasabi.Fluent.Controls
+{
+ public class HistoryPlaceholderPanel : ContentControl
+ {
+ private ItemsControl? _targetItemsControl;
+
+ public double RowHeight { get; set; } = 36.5;
+
+ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
+ {
+ _targetItemsControl = e.NameScope.Find<ItemsControl>("PART_DummyRows");
+ InvalidateMeasure();
+ base.OnApplyTemplate(e);
+ }
+
+ protected override Size MeasureOverride(Size availableSize)
+ {
+ if (_targetItemsControl is null)
+ {
+ return availableSize;
+ }
+
+ var totalRows = (int) Math.Floor(Math.Max(1, availableSize.Height / RowHeight));
+
+ var deltaOpacity = 1d / totalRows;
+
+ _targetItemsControl.Items =
+ Enumerable
+ .Range(1, totalRows)
+ .Reverse()
+ .Select(mult => mult * deltaOpacity)
+ .ToList();
+
+ return base.MeasureOverride(availableSize);
+ }
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Styles/Styles.axaml
WalletWasabi.Fluent/Styles/Styles.axaml
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/HyperlinkButton.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/AnimatedButton.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/CurrencyEntryBox.axaml" />
+ <StyleInclude Source="avares://WalletWasabi.Fluent/Controls/HistoryPlaceholderPanel.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/DataGrid.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/DataBox.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/RadioButton.axaml" />

MODIFY
WalletWasabi.Fluent/Styles/Themes/Base.axaml
WalletWasabi.Fluent/Styles/Themes/Base.axaml
<Styles xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:system="clr-namespace:System;assembly=System.Runtime">
<Styles.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<GradientStop Offset="1" Color="#FF7FAF2F" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
+
+ <system:Double x:Key="HistoryTableRowHeight">36.5</system:Double>
+ <Thickness x:Key="HistoryTablePlaceholderPanelMargin">0 42 0 0</Thickness>
+
</Styles.Resources>
</Styles>

make a placeholder control instead