feat: template binding
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Controls.Primitives;
|
||||
@@ -12,4 +13,41 @@ public class RangeSlider: TemplatedControl
|
||||
public const string PART_DecreaseButton = "PART_DecreaseButton";
|
||||
public const string PART_IncreaseButton = "PART_IncreaseButton";
|
||||
public const string PART_Track = "PART_Track";
|
||||
|
||||
public static readonly StyledProperty<double> MinimumProperty = RangeTrack.MinimumProperty.AddOwner<RangeSlider>();
|
||||
public double Minimum
|
||||
{
|
||||
get => GetValue(MinimumProperty);
|
||||
set => SetValue(MinimumProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<double> MaximumProperty = RangeTrack.MaximumProperty.AddOwner<RangeSlider>();
|
||||
public double Maximum
|
||||
{
|
||||
get => GetValue(MaximumProperty);
|
||||
set => SetValue(MaximumProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<double> LowerValueProperty = RangeTrack.LowerValueProperty.AddOwner<RangeSlider>();
|
||||
public double LowerValue
|
||||
{
|
||||
get => GetValue(LowerValueProperty);
|
||||
set => SetValue(LowerValueProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<double> UpperValueProperty = RangeTrack.UpperValueProperty.AddOwner<RangeSlider>();
|
||||
public double UpperValue
|
||||
{
|
||||
get => GetValue(UpperValueProperty);
|
||||
set => SetValue(UpperValueProperty, value);
|
||||
}
|
||||
|
||||
static RangeSlider()
|
||||
{
|
||||
MinimumProperty.OverrideDefaultValue<RangeSlider>(0);
|
||||
MaximumProperty.OverrideDefaultValue<RangeSlider>(100);
|
||||
LowerValueProperty.OverrideDefaultValue<RangeSlider>(0);
|
||||
UpperValueProperty.OverrideDefaultValue<RangeSlider>(100);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Layout;
|
||||
@@ -23,7 +24,7 @@ public class RangeTrack: Control
|
||||
private Vector _lastDrag;
|
||||
|
||||
public static readonly StyledProperty<double> MinimumProperty = AvaloniaProperty.Register<RangeTrack, double>(
|
||||
nameof(Minimum), coerce: CoerceMinimum);
|
||||
nameof(Minimum), coerce: CoerceMinimum, defaultBindingMode:BindingMode.TwoWay);
|
||||
|
||||
public double Minimum
|
||||
{
|
||||
@@ -32,7 +33,7 @@ public class RangeTrack: Control
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<double> MaximumProperty = AvaloniaProperty.Register<RangeTrack, double>(
|
||||
nameof(Maximum), coerce: CoerceMaximum);
|
||||
nameof(Maximum), coerce: CoerceMaximum, defaultBindingMode: BindingMode.TwoWay);
|
||||
|
||||
public double Maximum
|
||||
{
|
||||
@@ -41,7 +42,7 @@ public class RangeTrack: Control
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<double> LowerValueProperty = AvaloniaProperty.Register<RangeTrack, double>(
|
||||
nameof(LowerValue), coerce: CoerceLowerValue);
|
||||
nameof(LowerValue), coerce: CoerceLowerValue, defaultBindingMode: BindingMode.TwoWay);
|
||||
|
||||
public double LowerValue
|
||||
{
|
||||
@@ -50,7 +51,7 @@ public class RangeTrack: Control
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<double> UpperValueProperty = AvaloniaProperty.Register<RangeTrack, double>(
|
||||
nameof(UpperValue), coerce: CoerceUpperValue);
|
||||
nameof(UpperValue), coerce: CoerceUpperValue, defaultBindingMode: BindingMode.TwoWay);
|
||||
|
||||
public double UpperValue
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user