diff --git a/samples/ControlCatalog/Pages/SliderPage.xaml b/samples/ControlCatalog/Pages/SliderPage.xaml
index c6f5521e60..ca289e21fd 100644
--- a/samples/ControlCatalog/Pages/SliderPage.xaml
+++ b/samples/ControlCatalog/Pages/SliderPage.xaml
@@ -6,11 +6,21 @@
A control that lets the user select from a range of values by moving a Thumb control along a Track.
-
+
+
+
+
("CustomTickedSlider");
+ slider.Ticks = new List
+ {
+ 0d,
+ 5d,
+ 20d,
+ 50d,
+ 100d
+ };
}
}
}
diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs
index fe1a4f5ac1..00a26a4c91 100644
--- a/src/Avalonia.Controls/Slider.cs
+++ b/src/Avalonia.Controls/Slider.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using Avalonia.Controls.Mixins;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
@@ -64,6 +65,12 @@ namespace Avalonia.Controls
public static readonly StyledProperty TickPlacementProperty =
AvaloniaProperty.Register(nameof(TickPlacement), 0d);
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty> TicksProperty =
+ TickBar.TicksProperty.AddOwner();
+
// Slider required parts
private bool _isDragging = false;
private Track _track;
@@ -83,7 +90,8 @@ namespace Avalonia.Controls
PressedMixin.Attach();
OrientationProperty.OverrideDefaultValue(typeof(Slider), Orientation.Horizontal);
Thumb.DragStartedEvent.AddClassHandler((x, e) => x.OnThumbDragStarted(e), RoutingStrategies.Bubble);
- Thumb.DragCompletedEvent.AddClassHandler((x, e) => x.OnThumbDragCompleted(e), RoutingStrategies.Bubble);
+ Thumb.DragCompletedEvent.AddClassHandler((x, e) => x.OnThumbDragCompleted(e),
+ RoutingStrategies.Bubble);
}
///
@@ -94,6 +102,15 @@ namespace Avalonia.Controls
UpdatePseudoClasses(Orientation);
}
+ ///
+ /// Defines the ticks to be drawn on the tick bar.
+ ///
+ public List Ticks
+ {
+ get => GetValue(TicksProperty);
+ set => SetValue(TicksProperty, value);
+ }
+
///
/// Gets or sets the orientation of a .
///
diff --git a/src/Avalonia.Themes.Default/Slider.xaml b/src/Avalonia.Themes.Default/Slider.xaml
index 1d48a946fc..ba4b1ee998 100644
--- a/src/Avalonia.Themes.Default/Slider.xaml
+++ b/src/Avalonia.Themes.Default/Slider.xaml
@@ -87,7 +87,10 @@
-
+
+
diff --git a/src/Avalonia.Themes.Fluent/Slider.xaml b/src/Avalonia.Themes.Fluent/Slider.xaml
index 539c448e0f..099c2000b8 100644
--- a/src/Avalonia.Themes.Fluent/Slider.xaml
+++ b/src/Avalonia.Themes.Fluent/Slider.xaml
@@ -182,6 +182,7 @@