diff --git a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml
index a0cbefa4d9..dfe8be2cec 100644
--- a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml
+++ b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml
@@ -1,7 +1,25 @@
-
-
-
+
+
+ ItemsRepeater
+ A data-driven collection control that incorporates a flexible layout system, custom views, and virtualization.
+
+
+
+ Stack - Vertical
+ Stack - Horizontal
+ UniformGrid - Vertical
+ UniformGrid - Horizontal
+
+
+
+
+
+
+
+
diff --git a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs
index a6ca27cb67..dccb242a78 100644
--- a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs
+++ b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs
@@ -3,17 +3,23 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Avalonia.Controls;
+using Avalonia.Controls.Primitives;
+using Avalonia.Controls.Repeaters;
using Avalonia.Markup.Xaml;
namespace ControlCatalog.Pages
{
public class ItemsRepeaterPage : UserControl
{
+ private ItemsRepeater _repeater;
+ private ScrollViewer _scroller;
+
public ItemsRepeaterPage()
{
this.InitializeComponent();
- DataContext = Enumerable.Range(1, 100000).Select(i => $"Item {i}" )
- .ToArray();
+ _repeater = this.FindControl("repeater");
+ _scroller = this.FindControl("scroller");
+ DataContext = Enumerable.Range(1, 100000).Select(i => $"Item {i}" ).ToArray();
}
private void InitializeComponent()
@@ -21,5 +27,48 @@ namespace ControlCatalog.Pages
AvaloniaXamlLoader.Load(this);
}
+ private void LayoutChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (_repeater == null)
+ {
+ return;
+ }
+
+ var comboBox = (ComboBox)sender;
+
+ switch (comboBox.SelectedIndex)
+ {
+ case 0:
+ _scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
+ _scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
+ _repeater.Layout = new StackLayout { Orientation = Orientation.Vertical };
+ break;
+ case 1:
+ _scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
+ _scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
+ _repeater.Layout = new StackLayout { Orientation = Orientation.Horizontal };
+ break;
+ case 2:
+ _scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
+ _scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
+ _repeater.Layout = new UniformGridLayout
+ {
+ Orientation = Orientation.Vertical,
+ MinItemWidth = 200,
+ MinItemHeight = 200,
+ };
+ break;
+ case 3:
+ _scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
+ _scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
+ _repeater.Layout = new UniformGridLayout
+ {
+ Orientation = Orientation.Horizontal,
+ MinItemWidth = 200,
+ MinItemHeight = 200,
+ };
+ break;
+ }
+ }
}
}