feat: introducing background and foreground setting for loading container.

This commit is contained in:
rabbitism
2024-09-20 23:02:36 +08:00
parent 04a9945b54
commit 150ff5410a
2 changed files with 14 additions and 0 deletions

View File

@@ -93,6 +93,8 @@
<ControlTheme x:Key="{x:Type u:LoadingContainer}" TargetType="u:LoadingContainer">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="MessageForeground" Value="{DynamicResource TextBlockDefaultForeground}"/>
<Setter Property="Background" Value="{DynamicResource LoadingMaskBackground}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Indicator">
<Template>
@@ -109,6 +111,8 @@
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
<u:Loading
Background="{TemplateBinding Background}"
Foreground="{TemplateBinding MessageForeground}"
Content="{TemplateBinding LoadingMessage}"
ContentTemplate="{TemplateBinding LoadingMessageTemplate}"
Indicator="{TemplateBinding Indicator}"

View File

@@ -2,6 +2,7 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Templates;
using Avalonia.Media;
namespace Ursa.Controls;
@@ -28,6 +29,15 @@ public class LoadingContainer: ContentControl
set => SetValue(LoadingMessageProperty, value);
}
public static readonly StyledProperty<IBrush?> MessageForegroundProperty = AvaloniaProperty.Register<LoadingContainer, IBrush?>(
nameof(MessageForeground));
public IBrush? MessageForeground
{
get => GetValue(MessageForegroundProperty);
set => SetValue(MessageForegroundProperty, value);
}
public static readonly StyledProperty<IDataTemplate> LoadingMessageTemplateProperty = AvaloniaProperty.Register<LoadingContainer, IDataTemplate>(
nameof(LoadingMessageTemplate));