From d8d9a1865dc4abe7466a43f14edbab7262222f7a Mon Sep 17 00:00:00 2001 From: Mihai Stan Date: Thu, 2 Jul 2020 16:34:28 +0200 Subject: [PATCH] Use AvaloniaList instead of List --- samples/ControlCatalog/Pages/SliderPage.xaml | 1 + samples/ControlCatalog/Pages/SliderPage.xaml.cs | 11 ----------- src/Avalonia.Controls/Slider.cs | 8 ++++---- src/Avalonia.Controls/TickBar.cs | 12 ++++-------- 4 files changed, 9 insertions(+), 23 deletions(-) diff --git a/samples/ControlCatalog/Pages/SliderPage.xaml b/samples/ControlCatalog/Pages/SliderPage.xaml index ca289e21fd..ea31ed0050 100644 --- a/samples/ControlCatalog/Pages/SliderPage.xaml +++ b/samples/ControlCatalog/Pages/SliderPage.xaml @@ -19,6 +19,7 @@ Maximum="100" TickPlacement="BottomRight" IsSnapToTickEnabled="True" + Ticks="0,20,25,40,75,100" Width="300" /> ("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 b94f9bb7c9..293cbac82f 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; +using Avalonia.Collections; using Avalonia.Controls.Mixins; using Avalonia.Controls.Primitives; using Avalonia.Input; @@ -68,7 +68,7 @@ namespace Avalonia.Controls /// /// Defines the property. /// - public static readonly StyledProperty> TicksProperty = + public static readonly StyledProperty> TicksProperty = TickBar.TicksProperty.AddOwner(); // Slider required parts @@ -105,7 +105,7 @@ namespace Avalonia.Controls /// /// Defines the ticks to be drawn on the tick bar. /// - public List Ticks + public AvaloniaList Ticks { get => GetValue(TicksProperty); set => SetValue(TicksProperty, value); @@ -263,7 +263,7 @@ namespace Avalonia.Controls double next = Maximum; // This property is rarely set so let's try to avoid the GetValue - List ticks = Ticks; + var ticks = Ticks; // If ticks collection is available, use it. // Note that ticks may be unsorted. diff --git a/src/Avalonia.Controls/TickBar.cs b/src/Avalonia.Controls/TickBar.cs index 16e063beb3..22145d8742 100644 --- a/src/Avalonia.Controls/TickBar.cs +++ b/src/Avalonia.Controls/TickBar.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using Avalonia.Controls.Primitives; -using Avalonia.Data; -using Avalonia.Data.Converters; +using Avalonia.Collections; using Avalonia.Layout; using Avalonia.Media; using Avalonia.Utilities; @@ -135,15 +131,15 @@ namespace Avalonia.Controls /// /// Defines the property. /// - public static readonly StyledProperty> TicksProperty = - AvaloniaProperty.Register>(nameof(Ticks)); + public static readonly StyledProperty> TicksProperty = + AvaloniaProperty.Register>(nameof(Ticks)); /// /// The Ticks property contains collection of value of type Double which /// are the logical positions use to draw the ticks. /// The property value is a . /// - public List Ticks + public AvaloniaList Ticks { get { return GetValue(TicksProperty); } set { SetValue(TicksProperty, value); }