diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml
index c99a6b117b..874560a294 100644
--- a/samples/ControlCatalog/MainView.xaml
+++ b/samples/ControlCatalog/MainView.xaml
@@ -34,7 +34,8 @@
+ ScrollViewer.VerticalScrollBarVisibility="Disabled"
+ ScrollViewer.HorizontalScrollBarVisibility="Disabled">
diff --git a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml
index d0631d2cbd..103c016298 100644
--- a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml
+++ b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml
@@ -14,12 +14,19 @@
UniformGrid - Horizontal
+
-
+
+
+
+
+
+
+
diff --git a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs
index 1a607342f3..decd849adc 100644
--- a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs
+++ b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs
@@ -74,7 +74,7 @@ namespace ControlCatalog.Pages
private void RepeaterClick(object sender, PointerPressedEventArgs e)
{
- var item = (e.Source as TextBlock)?.DataContext as string;
+ var item = (e.Source as TextBlock)?.DataContext as ItemsRepeaterPageViewModel.Item;
((ItemsRepeaterPageViewModel)DataContext).SelectedItem = item;
}
}
diff --git a/samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs b/samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs
index 25fd550520..bc2ce80714 100644
--- a/samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs
+++ b/samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs
@@ -1,4 +1,5 @@
-using System.Collections.ObjectModel;
+using System;
+using System.Collections.ObjectModel;
using System.Linq;
using ReactiveUI;
@@ -10,18 +11,44 @@ namespace ControlCatalog.ViewModels
public ItemsRepeaterPageViewModel()
{
- Items = new ObservableCollection(
- Enumerable.Range(1, 100000).Select(i => $"Item {i.ToString()}"));
+ Items = new ObservableCollection- (
+ Enumerable.Range(1, 100000).Select(i => new Item
+ {
+ Text = $"Item {i.ToString()}",
+ }));
}
- public ObservableCollection Items { get; }
+ public ObservableCollection
- Items { get; }
- public string SelectedItem { get; set; }
+ public Item SelectedItem { get; set; }
public void AddItem()
{
var index = SelectedItem != null ? Items.IndexOf(SelectedItem) : -1;
- Items.Insert(index + 1, $"New Item {newItemIndex++}");
+ Items.Insert(index + 1, new Item { Text = $"New Item {newItemIndex++}" });
+ }
+
+ public void RandomizeHeights()
+ {
+ var random = new Random();
+
+ foreach (var i in Items)
+ {
+ i.Height = random.Next(240) + 10;
+ }
+ }
+
+ public class Item : ReactiveObject
+ {
+ private double _height = double.NaN;
+
+ public string Text { get; set; }
+
+ public double Height
+ {
+ get => _height;
+ set => this.RaiseAndSetIfChanged(ref _height, value);
+ }
}
}
}
diff --git a/src/Avalonia.Controls/Primitives/Track.cs b/src/Avalonia.Controls/Primitives/Track.cs
index 21a7dd68f8..a569808b35 100644
--- a/src/Avalonia.Controls/Primitives/Track.cs
+++ b/src/Avalonia.Controls/Primitives/Track.cs
@@ -1,10 +1,13 @@
-// Copyright (c) The Avalonia Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
+// Portions of this source file are adapted from the Windows Presentation Foundation project.
+// (https://github.com/dotnet/wpf/)
+//
+// Licensed to The Avalonia Project under MIT License, courtesy of The .NET Foundation.
using System;
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Metadata;
+using Avalonia.Utilities;
namespace Avalonia.Controls.Primitives
{
@@ -34,6 +37,9 @@ namespace Avalonia.Controls.Primitives
public static readonly StyledProperty