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"
TickPlacement="BottomRight"
IsSnapToTickEnabled="True"
Ticks="0,20,25,40,75,100"
Width="300" />
</StackPanel>
<Slider Value="0"

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

@ -1,4 +1,3 @@
using System.Collections.Generic;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
@ -14,16 +13,6 @@ namespace ControlCatalog.Pages
private void InitializeComponent()
{
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.Collections.Generic;
using Avalonia.Collections;
using Avalonia.Controls.Mixins;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
@ -68,7 +68,7 @@ namespace Avalonia.Controls
/// <summary>
/// Defines the <see cref="TicksProperty"/> property.
/// </summary>
public static readonly StyledProperty<List<double>> TicksProperty =
public static readonly StyledProperty<AvaloniaList<double>> TicksProperty =
TickBar.TicksProperty.AddOwner<Slider>();
// Slider required parts
@ -105,7 +105,7 @@ namespace Avalonia.Controls
/// <summary>
/// Defines the ticks to be drawn on the tick bar.
/// </summary>
public List<double> Ticks
public AvaloniaList<double> 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<double> ticks = Ticks;
var ticks = Ticks;
// If ticks collection is available, use it.
// Note that ticks may be unsorted.

12
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
/// <summary>
/// Defines the <see cref="Ticks"/> property.
/// </summary>
public static readonly StyledProperty<List<double>> TicksProperty =
AvaloniaProperty.Register<TickBar, List<double>>(nameof(Ticks));
public static readonly StyledProperty<AvaloniaList<double>> TicksProperty =
AvaloniaProperty.Register<TickBar, AvaloniaList<double>>(nameof(Ticks));
/// <summary>
/// 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 <see cref="DoubleCollection" />.
/// </summary>
public List<double> Ticks
public AvaloniaList<double> Ticks
{
get { return GetValue(TicksProperty); }
set { SetValue(TicksProperty, value); }

Loading…
Cancel
Save