61 lines
1.4 KiB
C#
61 lines
1.4 KiB
C#
using Avalonia;
|
|
using Avalonia.Controls;
|
|
|
|
namespace AutoCat.Views;
|
|
|
|
public partial class ReportTextItem : UserControl
|
|
{
|
|
#region Dependency properties
|
|
|
|
public static readonly StyledProperty<string> LabelProperty =
|
|
AvaloniaProperty.Register<ReportTextItem, string>(nameof(Label));
|
|
|
|
public static readonly StyledProperty<string> ValueProperty =
|
|
AvaloniaProperty.Register<ReportTextItem, string>(nameof(Value));
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
public string Label
|
|
{
|
|
get => GetValue(LabelProperty);
|
|
set => SetValue(LabelProperty, value);
|
|
}
|
|
|
|
public string Value
|
|
{
|
|
get => GetValue(ValueProperty);
|
|
set => SetValue(ValueProperty, value);
|
|
}
|
|
|
|
#endregion
|
|
|
|
static ReportTextItem()
|
|
{
|
|
LabelProperty.Changed.AddClassHandler<ReportTextItem>((v, e) => v.ValueChanged(e));
|
|
ValueProperty.Changed.AddClassHandler<ReportTextItem>((v, e) => v.ValueChanged(e));
|
|
}
|
|
|
|
public ReportTextItem()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void ValueChanged(AvaloniaPropertyChangedEventArgs e)
|
|
{
|
|
if (e.NewValue is not string newValue)
|
|
return;
|
|
|
|
if (e.Property == LabelProperty)
|
|
{
|
|
LabelBlock.Text = newValue;
|
|
}
|
|
|
|
if (e.Property == ValueProperty)
|
|
{
|
|
ValueBlock.Text = newValue;
|
|
}
|
|
}
|
|
|
|
} |