apply classes to content area contents to allow styling seperately.
MODIFY
WalletWasabi.Fluent/Controls/ContentArea.axaml
WalletWasabi.Fluent/Controls/ContentArea.axaml
<DockPanel Name="PART_DockPanel" >
<StackPanel Name="PART_StackPanel" DockPanel.Dock="Top" Spacing="10">
<ContentPresenter Name="PART_TitlePresenter" Content="{TemplateBinding Title}" />
- <TextBlock Name="PART_CaptionPresenter" Text="{TemplateBinding Caption}" />
+ <ContentPresenter Name="PART_CaptionPresenter" Content="{TemplateBinding Caption}" />
</StackPanel>
<ContentPresenter Name="PART_ContentPresenter"
Background="{TemplateBinding Background}"
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="TextBlock.FontSize" Value="24" />
</Style>
- <Style Selector="c|ContentArea /template/ TextBlock#PART_CaptionPresenter">
+ <Style Selector="c|ContentArea :is(Control).caption TextBlock, c|ContentArea :is(TextBlock).caption">
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="FontSize" Value="14" />
<Setter Property="TextWrapping" Value="Wrap" />

MODIFY
WalletWasabi.Fluent/Controls/ContentArea.axaml.cs
WalletWasabi.Fluent/Controls/ContentArea.axaml.cs
@@ -12,6 +12,9 @@ namespace WalletWasabi.Fluent.Controls
public static readonly StyledProperty<object> CaptionProperty =
AvaloniaProperty.Register<ContentArea, object>(nameof(Caption));
+ private IContentPresenter? _titlePresenter;
+ private IContentPresenter? _captionPresenter;
+
public object Title
{
get => GetValue(TitleProperty);
@@ -31,12 +34,47 @@ namespace WalletWasabi.Fluent.Controls
switch (presenter.Name)
{
case "PART_TitlePresenter":
+ if (_titlePresenter is {})
+ {
+ _titlePresenter.PropertyChanged -= PresenterOnPropertyChanged;
+ }
+
+ _titlePresenter = presenter;
+ _titlePresenter.PropertyChanged += PresenterOnPropertyChanged;
+ result = true;
+ break;
+
case "PART_CaptionPresenter":
+ if (_captionPresenter is {})
+ {
+ _captionPresenter.PropertyChanged -= PresenterOnPropertyChanged;
+ }
+
+ _captionPresenter = presenter;
+ _captionPresenter.PropertyChanged += PresenterOnPropertyChanged;
result = true;
break;
}
return result;
}
+
+ private void PresenterOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
+ {
+ if (e.Property == ContentPresenter.ChildProperty)
+ {
+ var className = sender == _captionPresenter ? "caption" : "title";
+
+ if (e.OldValue is IStyledElement oldValue)
+ {
+ oldValue.Classes.Remove(className);
+ }
+
+ if (e.NewValue is IStyledElement newValue)
+ {
+ newValue.Classes.Add(className);
+ }
+ }
+ }
}
}

apply classes to content area contents to allow styling seperately.