Browse Source

Use AvaloniaList instead of List

pull/4219/head
Mihai Stan 6 years ago
parent
commit
d8d9a1865d
  1. 1
      samples/ControlCatalog/Pages/SliderPage.xaml
  2. 11
      samples/ControlCatalog/Pages/SliderPage.xaml.cs
  3. 8
      src/Avalonia.Controls/Slider.cs
  4. 12
      src/Avalonia.Controls/TickBar.cs

1
samples/ControlCatalog/Pages/SliderPage.xaml

@ -19,6 +19,7 @@
Maximum="100" Maximum="100"
TickPlacement="BottomRight" TickPlacement="BottomRight"
IsSnapToTickEnabled="True" IsSnapToTickEnabled="True"
Ticks="0,20,25,40,75,100"
Width="300" /> Width="300" />
</StackPanel> </StackPanel>
<Slider Value="0" <Slider Value="0"

11
samples/ControlCatalog/Pages/SliderPage.xaml.cs

@ -1,4 +1,3 @@
using System.Collections.Generic;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
@ -14,16 +13,6 @@ namespace ControlCatalog.Pages
private void InitializeComponent() private void InitializeComponent()
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
var slider = this.FindControl<Slider>("CustomTickedSlider");
slider.Ticks = new List<double>
{
0d,
5d,
20d,
50d,
100d
};
} }
} }
} }

8
src/Avalonia.Controls/Slider.cs

@ -1,5 +1,5 @@
using System; using System;
using System.Collections.Generic; using Avalonia.Collections;
using Avalonia.Controls.Mixins; using Avalonia.Controls.Mixins;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using Avalonia.Input; using Avalonia.Input;
@ -68,7 +68,7 @@ namespace Avalonia.Controls
/// <summary> /// <summary>
/// Defines the <see cref="TicksProperty"/> property. /// Defines the <see cref="TicksProperty"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<List<double>> TicksProperty = public static readonly StyledProperty<AvaloniaList<double>> TicksProperty =
TickBar.TicksProperty.AddOwner<Slider>(); TickBar.TicksProperty.AddOwner<Slider>();
// Slider required parts // Slider required parts
@ -105,7 +105,7 @@ namespace Avalonia.Controls
/// <summary> /// <summary>
/// Defines the ticks to be drawn on the tick bar. /// Defines the ticks to be drawn on the tick bar.
/// </summary> /// </summary>
public List<double> Ticks public AvaloniaList<double> Ticks
{ {
get => GetValue(TicksProperty); get => GetValue(TicksProperty);
set => SetValue(TicksProperty, value); set => SetValue(TicksProperty, value);
@ -263,7 +263,7 @@ namespace Avalonia.Controls
double next = Maximum; double next = Maximum;
// This property is rarely set so let's try to avoid the GetValue // This property is rarely set so let's try to avoid the GetValue
List<double> ticks = Ticks; var ticks = Ticks;
// If ticks collection is available, use it. // If ticks collection is available, use it.
// Note that ticks may be unsorted. // Note that ticks may be unsorted.

12
src/Avalonia.Controls/TickBar.cs

@ -1,8 +1,4 @@
using System; using Avalonia.Collections;
using System.Collections.Generic;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.Data.Converters;
using Avalonia.Layout; using Avalonia.Layout;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.Utilities; using Avalonia.Utilities;
@ -135,15 +131,15 @@ namespace Avalonia.Controls
/// <summary> /// <summary>
/// Defines the <see cref="Ticks"/> property. /// Defines the <see cref="Ticks"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<List<double>> TicksProperty = public static readonly StyledProperty<AvaloniaList<double>> TicksProperty =
AvaloniaProperty.Register<TickBar, List<double>>(nameof(Ticks)); AvaloniaProperty.Register<TickBar, AvaloniaList<double>>(nameof(Ticks));
/// <summary> /// <summary>
/// The Ticks property contains collection of value of type Double which /// The Ticks property contains collection of value of type Double which
/// are the logical positions use to draw the ticks. /// are the logical positions use to draw the ticks.
/// The property value is a <see cref="DoubleCollection" />. /// The property value is a <see cref="DoubleCollection" />.
/// </summary> /// </summary>
public List<double> Ticks public AvaloniaList<double> Ticks
{ {
get { return GetValue(TicksProperty); } get { return GetValue(TicksProperty); }
set { SetValue(TicksProperty, value); } set { SetValue(TicksProperty, value); }

Loading…
Cancel
Save