From 1a60dc9e0b3f814e606b806a50fdc05ad545c00a Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Mon, 14 Sep 2026 17:56:47 -0700 Subject: [PATCH 1/3] Add experimental control samples Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- WinUIGallery/MainWindow.xaml | 30 ++ WinUIGallery/MainWindow.xaml.cs | 16 +- .../SampleSupport/Data/ControlInfoData.json | 124 +++++++- .../Samples/FlowLayout/FlowLayoutPage.xaml | 141 +++++++++ .../Samples/FlowLayout/FlowLayoutPage.xaml.cs | 103 +++++++ .../FlowLayout/FlowLayoutVirtualization.txt | 29 ++ .../Samples/LayoutPanel/FeaturedTileLayout.cs | 90 ++++++ .../LayoutPanel/LayoutPanelCustomLayout.txt | 61 ++++ .../Samples/LayoutPanel/LayoutPanelPage.xaml | 146 +++++++++ .../LayoutPanel/LayoutPanelPage.xaml.cs | 44 +++ .../PagerControl/PagerControlBasic.txt | 8 + .../PagerControl/PagerControlDisplayModes.txt | 19 ++ .../PagerControl/PagerControlPage.xaml | 100 ++++++ .../PagerControl/PagerControlPage.xaml.cs | 14 + .../PagerControl/PagerControlUnbounded.txt | 17 ++ .../Samples/WrapPanel/WrapPanelBasic.txt | 41 +++ .../WrapPanel/WrapPanelItemsStretch.txt | 27 ++ .../Samples/WrapPanel/WrapPanelPage.xaml | 289 ++++++++++++++++++ .../Samples/WrapPanel/WrapPanelPage.xaml.cs | 61 ++++ 19 files changed, 1356 insertions(+), 4 deletions(-) create mode 100644 WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml create mode 100644 WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml.cs create mode 100644 WinUIGallery/Samples/FlowLayout/FlowLayoutVirtualization.txt create mode 100644 WinUIGallery/Samples/LayoutPanel/FeaturedTileLayout.cs create mode 100644 WinUIGallery/Samples/LayoutPanel/LayoutPanelCustomLayout.txt create mode 100644 WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml create mode 100644 WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml.cs create mode 100644 WinUIGallery/Samples/PagerControl/PagerControlBasic.txt create mode 100644 WinUIGallery/Samples/PagerControl/PagerControlDisplayModes.txt create mode 100644 WinUIGallery/Samples/PagerControl/PagerControlPage.xaml create mode 100644 WinUIGallery/Samples/PagerControl/PagerControlPage.xaml.cs create mode 100644 WinUIGallery/Samples/PagerControl/PagerControlUnbounded.txt create mode 100644 WinUIGallery/Samples/WrapPanel/WrapPanelBasic.txt create mode 100644 WinUIGallery/Samples/WrapPanel/WrapPanelItemsStretch.txt create mode 100644 WinUIGallery/Samples/WrapPanel/WrapPanelPage.xaml create mode 100644 WinUIGallery/Samples/WrapPanel/WrapPanelPage.xaml.cs diff --git a/WinUIGallery/MainWindow.xaml b/WinUIGallery/MainWindow.xaml index 38142f5f9..242548960 100644 --- a/WinUIGallery/MainWindow.xaml +++ b/WinUIGallery/MainWindow.xaml @@ -6,6 +6,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="using:WinUIGallery" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:models="using:WinUIGallery.Models" xmlns:pages="using:WinUIGallery.Pages" Title="MainWindow" mc:Ignorable="d"> @@ -144,6 +145,35 @@ IsTabStop="False" Loaded="OnNavigationViewControlLoaded" SelectionChanged="OnNavigationViewSelectionChanged"> + + + + + + + + + + + + + + i.Title).Where(i => !i.IsSpecialSection)) { var itemGroup = new NavigationViewItem() { Content = group.Title, Tag = group.UniqueId, DataContext = group, Icon = GetIcon(group.IconGlyph) }; @@ -258,14 +260,22 @@ public void AddNavigationMenuItems() foreach (var item in group.Items) { - var itemInGroup = new NavigationViewItem() { IsEnabled = item.IncludedInBuild, Content = item.Title, Tag = item.UniqueId, DataContext = item }; + var itemInGroup = new NavigationViewItem() + { + IsEnabled = item.IncludedInBuild, + Content = item, + ContentTemplate = navigationItemContentTemplate, + DataContext = item, + HorizontalContentAlignment = HorizontalAlignment.Stretch, + Tag = item.UniqueId, + }; var itemInGroupMenuFlyoutItem = new MenuFlyoutItem() { Text = $"Copy Link to {item.Title} sample", Icon = new FontIcon() { Glyph = "\uE8C8" }, Tag = item }; itemInGroupMenuFlyoutItem.Click += this.OnMenuFlyoutItemClick; itemInGroup.ContextFlyout = new MenuFlyout() { Items = { itemInGroupMenuFlyoutItem } }; itemGroup.MenuItems.Add(itemInGroup); - AutomationProperties.SetName(itemInGroup, item.Title); + AutomationProperties.SetName(itemInGroup, item.IsExperimental ? $"{item.Title}, Experimental" : item.Title); AutomationProperties.SetAutomationId(itemInGroup, item.UniqueId); } @@ -529,7 +539,7 @@ public bool EnsureItemIsVisibleInNavigation(string name) { foreach (NavigationViewItem child in item.MenuItems) { - if ((string)child.Content == name) + if (child.DataContext is ControlInfoDataItem childData && childData.Title == name) { // We are the item corresponding to the selected one, update selection! diff --git a/WinUIGallery/SampleSupport/Data/ControlInfoData.json b/WinUIGallery/SampleSupport/Data/ControlInfoData.json index 4e0fc9f7f..5b9079704 100644 --- a/WinUIGallery/SampleSupport/Data/ControlInfoData.json +++ b/WinUIGallery/SampleSupport/Data/ControlInfoData.json @@ -946,6 +946,39 @@ "SemanticZoom" ] }, + { + "UniqueId": "FlowLayout", + "Tags": [ + "flow layout", + "wrapping", + "virtualization", + "items repeater" + ], + "Title": "FlowLayout", + "BaseClasses": [ + "Object", + "DependencyObject", + "Layout", + "VirtualizingLayout" + ], + "ApiNamespace": "Microsoft.UI.Xaml.Controls", + "Subtitle": "A virtualizing layout that arranges items sequentially and wraps them onto new lines.", + "ImagePath": "ms-appx:///Assets/ControlImages/Placeholder.png", + "Description": "Use FlowLayout with an ItemsRepeater to create a virtualized, wrapping collection. Configure its orientation, minimum item and line spacing, and alignment within each line.", + "SourcePath": "/Repeater", + "IsExperimental": true, + "Docs": [ + { + "Title": "FlowLayout - API", + "Uri": "https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.flowlayout" + } + ], + "RelatedControls": [ + "ItemsRepeater", + "LinedFlowLayout", + "UniformGridLayout" + ] + }, { "UniqueId": "GridView", "Tags": [ @@ -2284,6 +2317,33 @@ "ItemsRepeater" ] }, + { + "UniqueId": "PagerControl", + "Tags": [ + "pagination", + "pages", + "navigation" + ], + "Title": "PagerControl", + "BaseClasses": [ + "Object", + "DependencyObject", + "UIElement", + "FrameworkElement", + "Control" + ], + "ApiNamespace": "Microsoft.UI.Xaml.Controls", + "Subtitle": "A control that lets users navigate through a numbered collection of pages.", + "ImagePath": "ms-appx:///Assets/ControlImages/Placeholder.png", + "Description": "PagerControl provides numbered page navigation with multiple display modes and configurable navigation buttons.", + "SourcePath": "/PagerControl", + "IsExperimental": true, + "RelatedControls": [ + "PipsPager", + "ItemsRepeater", + "ListView" + ] + }, { "UniqueId": "ScrollView", "Tags": [ @@ -2550,7 +2610,40 @@ "RelativePanel" ] }, - + { + "UniqueId": "LayoutPanel", + "Tags": [ + "layout panel", + "custom layout", + "non virtualizing layout", + "panel" + ], + "Title": "LayoutPanel", + "BaseClasses": [ + "Object", + "DependencyObject", + "UIElement", + "FrameworkElement", + "Panel" + ], + "ApiNamespace": "Microsoft.UI.Xaml.Controls", + "Subtitle": "A panel that uses a Layout object to measure and arrange its children.", + "ImagePath": "ms-appx:///Assets/ControlImages/Placeholder.png", + "Description": "Use LayoutPanel to apply a reusable Layout, including a custom NonVirtualizingLayout, to ordinary panel children. LayoutPanel also provides border, corner radius, and padding properties.", + "SourcePath": "/LayoutPanel", + "IsExperimental": true, + "Docs": [ + { + "Title": "LayoutPanel - API", + "Uri": "https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.layoutpanel" + } + ], + "RelatedControls": [ + "Panel", + "StackLayout", + "ItemsRepeater" + ] + }, { "UniqueId": "RelativePanel", "Tags": [ @@ -2699,6 +2792,35 @@ "RelativePanel" ] }, + { + "UniqueId": "WrapPanel", + "Tags": [ + "wrap", + "responsive layout", + "flow layout", + "spacing" + ], + "Title": "WrapPanel", + "BaseClasses": [ + "Object", + "DependencyObject", + "UIElement", + "FrameworkElement", + "Panel" + ], + "ApiNamespace": "Microsoft.UI.Xaml.Controls", + "Subtitle": "A layout panel that arranges child elements in rows or columns and automatically wraps them onto new lines.", + "ImagePath": "ms-appx:///Assets/ControlImages/Placeholder.png", + "Description": "Use a WrapPanel to arrange child elements sequentially and move overflowing items to a new row or column. You can configure its orientation, spacing, padding, and whether the final item stretches to fill the remaining space.", + "SourcePath": "/WrapPanel", + "IsExperimental": true, + "RelatedControls": [ + "StackPanel", + "VariableSizedWrapGrid", + "ItemsRepeater", + "GridView" + ] + }, { "UniqueId": "Viewbox", "Tags": [ diff --git a/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml b/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml new file mode 100644 index 000000000..05bb15932 --- /dev/null +++ b/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml.cs b/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml.cs new file mode 100644 index 000000000..d1bf9b06e --- /dev/null +++ b/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace WinUIGallery.ControlPages; + +public sealed partial class FlowLayoutPage : Page +{ + private readonly HashSet _realizedElements = []; + private bool _realizedCountUpdateQueued; + + public IReadOnlyList Items { get; } = Enumerable.Range(1, 500) + .Select(index => new FlowLayoutItem($"Item {index}")) + .ToList(); + + public FlowLayoutPage() + { + InitializeComponent(); + } + + private void OrientationButtons_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if ((sender as RadioButtons)?.SelectedItem is RadioButton selectedItem && + Enum.TryParse(selectedItem.Tag?.ToString(), out Orientation orientation) && + FlowLayout1 is not null) + { + FlowLayout1.Orientation = orientation; + + if (FlowScrollViewer is not null) + { + bool isHorizontal = orientation == Orientation.Horizontal; + FlowScrollViewer.HorizontalScrollMode = isHorizontal ? ScrollMode.Disabled : ScrollMode.Enabled; + FlowScrollViewer.HorizontalScrollBarVisibility = isHorizontal + ? ScrollBarVisibility.Disabled + : ScrollBarVisibility.Auto; + FlowScrollViewer.VerticalScrollMode = isHorizontal ? ScrollMode.Enabled : ScrollMode.Disabled; + FlowScrollViewer.VerticalScrollBarVisibility = isHorizontal + ? ScrollBarVisibility.Auto + : ScrollBarVisibility.Disabled; + } + } + } + + private void LineAlignmentComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if ((sender as ComboBox)?.SelectedItem is ComboBoxItem selectedItem && + Enum.TryParse(selectedItem.Tag?.ToString(), out FlowLayoutLineAlignment alignment) && + FlowLayout1 is not null) + { + FlowLayout1.LineAlignment = alignment; + } + } + + private void ItemSpacingSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) + { + if (FlowLayout1 is not null) + { + FlowLayout1.MinItemSpacing = e.NewValue; + } + } + + private void LineSpacingSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) + { + if (FlowLayout1 is not null) + { + FlowLayout1.LineSpacing = e.NewValue; + } + } + + private void FlowRepeater_ElementPrepared(ItemsRepeater sender, ItemsRepeaterElementPreparedEventArgs args) + { + _realizedElements.Add(args.Element); + QueueRealizedCountUpdate(); + } + + private void FlowRepeater_ElementClearing(ItemsRepeater sender, ItemsRepeaterElementClearingEventArgs args) + { + _realizedElements.Remove(args.Element); + QueueRealizedCountUpdate(); + } + + private void QueueRealizedCountUpdate() + { + if (_realizedCountUpdateQueued) + { + return; + } + + _realizedCountUpdateQueued = DispatcherQueue.TryEnqueue(() => + { + _realizedCountUpdateQueued = false; + RealizedCountText.Text = $"Realized elements: {_realizedElements.Count} of {Items.Count}"; + }); + } +} + +public sealed record FlowLayoutItem(string Label); diff --git a/WinUIGallery/Samples/FlowLayout/FlowLayoutVirtualization.txt b/WinUIGallery/Samples/FlowLayout/FlowLayoutVirtualization.txt new file mode 100644 index 000000000..2d6994e74 --- /dev/null +++ b/WinUIGallery/Samples/FlowLayout/FlowLayoutVirtualization.txt @@ -0,0 +1,29 @@ +--- header +Use FlowLayout with ItemsRepeater to wrap and virtualize a large collection. +--- xaml + + + + + + + + + + + + + +--- c# +public IReadOnlyList Items { get; } = Enumerable.Range(1, 500) + .Select(index => new FlowLayoutItem($"Item {index}")) + .ToList(); + +public sealed record FlowLayoutItem(string Label); diff --git a/WinUIGallery/Samples/LayoutPanel/FeaturedTileLayout.cs b/WinUIGallery/Samples/LayoutPanel/FeaturedTileLayout.cs new file mode 100644 index 000000000..f3d1c2ac5 --- /dev/null +++ b/WinUIGallery/Samples/LayoutPanel/FeaturedTileLayout.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using System; +using Windows.Foundation; + +namespace WinUIGallery.Layouts; + +public partial class FeaturedTileLayout : NonVirtualizingLayout +{ + public static readonly DependencyProperty SpacingProperty = DependencyProperty.Register( + nameof(Spacing), + typeof(double), + typeof(FeaturedTileLayout), + new PropertyMetadata(0d, OnSpacingChanged)); + + public double Spacing + { + get => (double)GetValue(SpacingProperty); + set => SetValue(SpacingProperty, value); + } + + protected override Size MeasureOverride(NonVirtualizingLayoutContext context, Size availableSize) + { + double width = double.IsInfinity(availableSize.Width) ? 520 : availableSize.Width; + double columnWidth = Math.Max(0, (width - Spacing) / 2); + + for (int index = 0; index < context.Children.Count; index++) + { + UIElement child = context.Children[index]; + child.Measure(new Size(index == 0 ? width : columnWidth, double.PositiveInfinity)); + } + + double totalHeight = context.Children.Count == 0 ? 0 : context.Children[0].DesiredSize.Height; + + for (int index = 1; index < context.Children.Count; index += 2) + { + totalHeight += Spacing + GetRowHeight(context, index); + } + + return new Size(width, totalHeight); + } + + protected override Size ArrangeOverride(NonVirtualizingLayoutContext context, Size finalSize) + { + if (context.Children.Count == 0) + { + return finalSize; + } + + double columnWidth = Math.Max(0, (finalSize.Width - Spacing) / 2); + UIElement featuredItem = context.Children[0]; + featuredItem.Arrange(new Rect(0, 0, finalSize.Width, featuredItem.DesiredSize.Height)); + double y = featuredItem.DesiredSize.Height; + + for (int index = 1; index < context.Children.Count; index += 2) + { + y += Spacing; + double rowHeight = GetRowHeight(context, index); + context.Children[index].Arrange(new Rect(0, y, columnWidth, rowHeight)); + + if (index + 1 < context.Children.Count) + { + context.Children[index + 1].Arrange(new Rect(columnWidth + Spacing, y, columnWidth, rowHeight)); + } + + y += rowHeight; + } + + return new Size(finalSize.Width, y); + } + + private static double GetRowHeight(NonVirtualizingLayoutContext context, int firstIndex) + { + double height = context.Children[firstIndex].DesiredSize.Height; + return firstIndex + 1 < context.Children.Count + ? Math.Max(height, context.Children[firstIndex + 1].DesiredSize.Height) + : height; + } + + private static void OnSpacingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) + { + if (sender is FeaturedTileLayout layout) + { + layout.InvalidateMeasure(); + } + } +} diff --git a/WinUIGallery/Samples/LayoutPanel/LayoutPanelCustomLayout.txt b/WinUIGallery/Samples/LayoutPanel/LayoutPanelCustomLayout.txt new file mode 100644 index 000000000..1585092cd --- /dev/null +++ b/WinUIGallery/Samples/LayoutPanel/LayoutPanelCustomLayout.txt @@ -0,0 +1,61 @@ +--- header +LayoutPanel lets a custom Layout arrange ordinary panel children. +--- xaml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +--- c# +public partial class FeaturedTileLayout : NonVirtualizingLayout +{ + protected override Size MeasureOverride( + NonVirtualizingLayoutContext context, + Size availableSize) + { + // Measure the first child at full width and the remaining + // children in two columns, then return the combined extent. + // See FeaturedTileLayout.cs in the WinUI Gallery for the + // complete measure and arrange implementation. + } + + protected override Size ArrangeOverride( + NonVirtualizingLayoutContext context, + Size finalSize) + { + // Arrange the first child across the panel. Arrange each + // subsequent pair in equal-width columns. + } +} diff --git a/WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml b/WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml new file mode 100644 index 000000000..5be769a8e --- /dev/null +++ b/WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml.cs b/WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml.cs new file mode 100644 index 000000000..f5b5fa7de --- /dev/null +++ b/WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using WinUIGallery.Layouts; + +namespace WinUIGallery.ControlPages; + +public sealed partial class LayoutPanelPage : Page +{ + private readonly StackLayout _stackLayout = new() { Orientation = Orientation.Vertical, Spacing = 8 }; + private FeaturedTileLayout? _featuredTileLayout; + + public LayoutPanelPage() + { + InitializeComponent(); + _featuredTileLayout = (FeaturedTileLayout)LayoutPanel1.Layout; + } + + private void LayoutButtons_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if ((sender as RadioButtons)?.SelectedItem is not RadioButton selectedItem || + LayoutPanel1 is null || + _featuredTileLayout is null) + { + return; + } + + LayoutPanel1.Layout = selectedItem.Tag?.ToString() == "Stack" + ? _stackLayout + : _featuredTileLayout; + } + + private void SpacingSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) + { + _stackLayout.Spacing = e.NewValue; + + if (_featuredTileLayout is not null) + { + _featuredTileLayout.Spacing = e.NewValue; + } + } +} diff --git a/WinUIGallery/Samples/PagerControl/PagerControlBasic.txt b/WinUIGallery/Samples/PagerControl/PagerControlBasic.txt new file mode 100644 index 000000000..4143240bc --- /dev/null +++ b/WinUIGallery/Samples/PagerControl/PagerControlBasic.txt @@ -0,0 +1,8 @@ +--- header +A basic pager +--- xaml + diff --git a/WinUIGallery/Samples/PagerControl/PagerControlDisplayModes.txt b/WinUIGallery/Samples/PagerControl/PagerControlDisplayModes.txt new file mode 100644 index 000000000..24a421c96 --- /dev/null +++ b/WinUIGallery/Samples/PagerControl/PagerControlDisplayModes.txt @@ -0,0 +1,19 @@ +--- header +Pager display modes +--- xaml + + + + diff --git a/WinUIGallery/Samples/PagerControl/PagerControlPage.xaml b/WinUIGallery/Samples/PagerControl/PagerControlPage.xaml new file mode 100644 index 000000000..336013c01 --- /dev/null +++ b/WinUIGallery/Samples/PagerControl/PagerControlPage.xaml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WinUIGallery/Samples/PagerControl/PagerControlPage.xaml.cs b/WinUIGallery/Samples/PagerControl/PagerControlPage.xaml.cs new file mode 100644 index 000000000..7b763500a --- /dev/null +++ b/WinUIGallery/Samples/PagerControl/PagerControlPage.xaml.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.UI.Xaml.Controls; + +namespace WinUIGallery.ControlPages; + +public sealed partial class PagerControlPage : Page +{ + public PagerControlPage() + { + InitializeComponent(); + } +} diff --git a/WinUIGallery/Samples/PagerControl/PagerControlUnbounded.txt b/WinUIGallery/Samples/PagerControl/PagerControlUnbounded.txt new file mode 100644 index 000000000..79344b86f --- /dev/null +++ b/WinUIGallery/Samples/PagerControl/PagerControlUnbounded.txt @@ -0,0 +1,17 @@ +--- header +Unbounded pagers +--- xaml + + + + diff --git a/WinUIGallery/Samples/WrapPanel/WrapPanelBasic.txt b/WinUIGallery/Samples/WrapPanel/WrapPanelBasic.txt new file mode 100644 index 000000000..ba89d2217 --- /dev/null +++ b/WinUIGallery/Samples/WrapPanel/WrapPanelBasic.txt @@ -0,0 +1,41 @@ +--- header +A WrapPanel that automatically wraps items when they reach the panel boundary. +--- xaml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WinUIGallery/Samples/WrapPanel/WrapPanelItemsStretch.txt b/WinUIGallery/Samples/WrapPanel/WrapPanelItemsStretch.txt new file mode 100644 index 000000000..10168ea95 --- /dev/null +++ b/WinUIGallery/Samples/WrapPanel/WrapPanelItemsStretch.txt @@ -0,0 +1,27 @@ +--- header +A WrapPanel that can stretch its final item to fill the remaining space. +--- xaml + + + + + + + + + + + + + + + + + + + + diff --git a/WinUIGallery/Samples/WrapPanel/WrapPanelPage.xaml b/WinUIGallery/Samples/WrapPanel/WrapPanelPage.xaml new file mode 100644 index 000000000..e13102e46 --- /dev/null +++ b/WinUIGallery/Samples/WrapPanel/WrapPanelPage.xaml @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WinUIGallery/Samples/WrapPanel/WrapPanelPage.xaml.cs b/WinUIGallery/Samples/WrapPanel/WrapPanelPage.xaml.cs new file mode 100644 index 000000000..ac020d193 --- /dev/null +++ b/WinUIGallery/Samples/WrapPanel/WrapPanelPage.xaml.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using System; + +namespace WinUIGallery.ControlPages; + +public sealed partial class WrapPanelPage : Page +{ + public WrapPanelPage() + { + InitializeComponent(); + } + + private void OrientationGroup_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if ((sender as RadioButtons)?.SelectedItem is not RadioButton selectedItem || + Enum.TryParse(selectedItem.Tag?.ToString(), out Orientation orientation) is false || + Control1 is null) + { + return; + } + + Control1.Orientation = orientation; + LayoutHost.Height = orientation == Orientation.Vertical ? 360 : 200; + } + + private void ItemSpacingSlider_ValueChanged(object sender, Microsoft.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e) + { + if (Control1 is not null) + { + Control1.ItemSpacing = e.NewValue; + } + } + + private void LineSpacingSlider_ValueChanged(object sender, Microsoft.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e) + { + if (Control1 is not null) + { + Control1.LineSpacing = e.NewValue; + } + } + + private void PaddingSlider_ValueChanged(object sender, Microsoft.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e) + { + if (Control1 is not null) + { + Control1.Padding = new Thickness(e.NewValue); + } + } + + private void StretchLastItemToggle_Toggled(object sender, RoutedEventArgs e) + { + if (sender is ToggleSwitch toggleSwitch && Control2 is not null) + { + Control2.ItemsStretch = toggleSwitch.IsOn ? WrapPanelItemsStretch.Last : WrapPanelItemsStretch.None; + } + } +} From 90c4e44f834fcab7326a81f90451b5b64ca6ea43 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Tue, 15 Sep 2026 12:48:02 +0200 Subject: [PATCH 2/3] Refine experimental control samples Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Assets/ControlImages/LayoutPanel.png | Bin 0 -> 3637 bytes .../Assets/ControlImages/PagerControl.png | Bin 0 -> 4775 bytes .../Assets/ControlImages/WrapPanel.png | Bin 0 -> 4478 bytes .../SampleSupport/Data/ControlInfoData.json | 39 +---- .../Samples/FlowLayout/FlowLayoutPage.xaml | 141 ------------------ .../Samples/FlowLayout/FlowLayoutPage.xaml.cs | 103 ------------- .../FlowLayoutVirtualization.txt | 4 +- .../ItemsRepeater/ItemsRepeaterPage.xaml | 118 +++++++++++++++ .../ItemsRepeater/ItemsRepeaterPage.xaml.cs | 87 +++++++++++ .../Samples/LayoutPanel/LayoutPanelPage.xaml | 2 +- 10 files changed, 211 insertions(+), 283 deletions(-) create mode 100644 WinUIGallery/Assets/ControlImages/LayoutPanel.png create mode 100644 WinUIGallery/Assets/ControlImages/PagerControl.png create mode 100644 WinUIGallery/Assets/ControlImages/WrapPanel.png delete mode 100644 WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml delete mode 100644 WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml.cs rename WinUIGallery/Samples/{FlowLayout => ItemsRepeater}/FlowLayoutVirtualization.txt (86%) diff --git a/WinUIGallery/Assets/ControlImages/LayoutPanel.png b/WinUIGallery/Assets/ControlImages/LayoutPanel.png new file mode 100644 index 0000000000000000000000000000000000000000..ba65f59bd7c3f349832252f3907f978dc6206093 GIT binary patch literal 3637 zcmV-54$AR~P)Os$c)Ax~gVOv~AnAZQHhO+qP}nwr$(C(0KZI>(!61?a0pSMauKz z;qG`+iUx=3$Nz!2PsU`(yV4E|e^ zq%;E~#>mI2i)pA}OBPnx4p*T}XdD*-LK8(ZD@{0H zIj<2DWq`y?Xd%e*0B~qF-U-&TB7qYMI@0YY_s-kRv5r?} zW;q8%0B{yFi<#0(^MH)TTr$TDY!+jV>6m~n6u`G}M}SJ|G^adeTPHNPhBys9OQ4la8&jomcA*|MIEZgOodu;-5JJOCA{{k>B_h4-V{M^+J^tqkE|? zh5!_e72L#%#`2agSuo}S-$U%CZCg(|7Ky-AcQLP#w2mBM`1pOgUe|xM6LYw13kTZI zsHH$O$*eJ2gw?Izcy2XC!*%tT*dkl&*A9F>o5TC4EY{EGHW?!l)#w~iX$L1KC)BbC z^s{I=?Xd1*Y{IH9LUViny<2pDy-&R2z4C!U>}*pe3M`7UoP(fht`9y$~US z;z^7Nq}9qn^*L4+#_K(HJpMhrdqfBO#|~16nRYTBB6ktr-rdZ`AMgEj1nF-lk&nSD z#Lv7v+6C{+9-EPL2_eA>;@I;ILSQcLcGpON+YklDL#4&%ozAWAV+_>EufK*(OE$Y8 zNo%~?Z*#(IL1U}O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PagerControl.png b/WinUIGallery/Assets/ControlImages/PagerControl.png new file mode 100644 index 0000000000000000000000000000000000000000..b8f7d26784f29b0829e90d86589f87c5cd371589 GIT binary patch literal 4775 zcmV;Y5?JktP)hVJct?AV#H=kCQmdp-BL*AZ&}Rdeh+_s+Td`K@m~_ZeX8+Pb!`t!wMry0)(G z(~I&iH$HmuTHe^)3)+nPJYoNR_}qHc-|hbJKGC*Q{e3F!H}l}ycXPNqd@-$aFM`{< z-fQg_qksKY=BsU5zdZKPZliu))HUh+o7N}YYhzoxjo91fFn|4SLPJ0Ke#+<8&j0?t z!yQ1^fBwZg7P0VP9eWwy#YI$c;aJ!3xuVA?Ozktb&9;?u89s2Ex|Gu1wT*OQY3TiI zyaJ!Y$7`LmUt#^;$3q?qI<1dcWJ2)JzNGf8{|c9K&$$CPJwi8p;pJN^Y=`nDrCG3R z48R31Z6b3kI7Nxz3zWqVgO|eHf*p(mK-;jkYyTVQ0<6w6v?Gi+&w^y(v^Jl=pQ955 z$6D$vw@>QN1NNl@(lAMY{Xf7lFywO+V=qO7-WGdqQ51foKqW}n>Fa4;!A5bb3$<^;PCKtlnV2Z9;t8CzsFU_{$t&y=L@c3>Lb zV#Y|Cl)Zgc!+xBRlyzgKcH)WJk`>&A@&6YAJ56EA6$NjuozOnc90OQ?cP6NWi*3qp$%buB*(r2PD>Ao^kyMG)772kYCM!Ok3A;^1 z14tKCF{DnN!~mn9NknNpW`yiIs|hK)WL-S64QLYcfRG)O%s%Qt7=KPei;2nAy_g=w znsT@?T6}x&jI_Pag26hNEr8J*UfF8~GsQ#!G-5GTq$Dw4=^2q0uU<%1VxHY&bRNqY z7ju==9uAb)moN_@Akqbs4%#uu5Vp;QJ-{f^9Rb9mTK2h^%K74p*i~bIZ-7#pF(X_M zl17lKip?ieD!A;bR|*Hnx>iboq=HN&23^((1BGQ!orF2kOkm8gWW<~q$cxl9*>?q* zA=Ik|5HSxUd%d`4Ig#2!&6Q+a(#RI(4=HRHcd9pQ#D}HS@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`~mC4y-)S8#7j2Pd>Xda4>@AOI#MN8$`H?zpf0d z_YTxN23(xJAbEOv29LO?%l#_SRA_)ce94-A!uM)LEfe`Bzp&QiXH2r3M6+`Za~FS- zzQ(^2AHrNIx=a2!Aw`*@#b;2nn^7|wE0LhtCm@147M16tq}3h8ARL7OzxUl=admyy zd_E;VMU}^$1cdr%ulV!5dk^8}M<-zJ6P|6B`#OS}G4pYEv5G>f2{x@6;=)alCF`V; zQH;0Pld`%>ENnh#w)zG&hN1FAi=yme3qY1B|KP1CIWp5tT`DQMnRf|Ju%x9{qs2h%A9xxS%UCEqFCJPz zwkkUd`ecRrzYyB^jTW)UtuL=9QIx%HLqtq=<>Q|M2Esu6Tf=!qJ?b`yZOFOwg0E2)$! zvn>MS(mG(lf40Yx{6ucnk;bP6(B)XwLSl=SV=I7f$YIdm@lfyZXva2)(fevO_H0e` zpmL_|8&c(|`~^e~lhXR7{n*0Fpv}LJZQ@cce1j{M_i8!inyfHwEF3S%kejW5gZO}t zG~QBK|LM*Dy3T@pjhFgny{SaHvgrIA5CzwWfpufzQo~^YP&Z^NDTJk!001l(QS6wRH_kgebke%dj|Koq(dJpz(-}Y_a_HEzxZQu57-?p{i08soj(HEHR Qng9R*07*qoM6N<$f&#aVzW@LL literal 0 HcmV?d00001 diff --git a/WinUIGallery/SampleSupport/Data/ControlInfoData.json b/WinUIGallery/SampleSupport/Data/ControlInfoData.json index 5b9079704..a10d193f7 100644 --- a/WinUIGallery/SampleSupport/Data/ControlInfoData.json +++ b/WinUIGallery/SampleSupport/Data/ControlInfoData.json @@ -946,39 +946,6 @@ "SemanticZoom" ] }, - { - "UniqueId": "FlowLayout", - "Tags": [ - "flow layout", - "wrapping", - "virtualization", - "items repeater" - ], - "Title": "FlowLayout", - "BaseClasses": [ - "Object", - "DependencyObject", - "Layout", - "VirtualizingLayout" - ], - "ApiNamespace": "Microsoft.UI.Xaml.Controls", - "Subtitle": "A virtualizing layout that arranges items sequentially and wraps them onto new lines.", - "ImagePath": "ms-appx:///Assets/ControlImages/Placeholder.png", - "Description": "Use FlowLayout with an ItemsRepeater to create a virtualized, wrapping collection. Configure its orientation, minimum item and line spacing, and alignment within each line.", - "SourcePath": "/Repeater", - "IsExperimental": true, - "Docs": [ - { - "Title": "FlowLayout - API", - "Uri": "https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.flowlayout" - } - ], - "RelatedControls": [ - "ItemsRepeater", - "LinedFlowLayout", - "UniformGridLayout" - ] - }, { "UniqueId": "GridView", "Tags": [ @@ -2334,7 +2301,7 @@ ], "ApiNamespace": "Microsoft.UI.Xaml.Controls", "Subtitle": "A control that lets users navigate through a numbered collection of pages.", - "ImagePath": "ms-appx:///Assets/ControlImages/Placeholder.png", + "ImagePath": "ms-appx:///Assets/ControlImages/PagerControl.png", "Description": "PagerControl provides numbered page navigation with multiple display modes and configurable navigation buttons.", "SourcePath": "/PagerControl", "IsExperimental": true, @@ -2628,7 +2595,7 @@ ], "ApiNamespace": "Microsoft.UI.Xaml.Controls", "Subtitle": "A panel that uses a Layout object to measure and arrange its children.", - "ImagePath": "ms-appx:///Assets/ControlImages/Placeholder.png", + "ImagePath": "ms-appx:///Assets/ControlImages/LayoutPanel.png", "Description": "Use LayoutPanel to apply a reusable Layout, including a custom NonVirtualizingLayout, to ordinary panel children. LayoutPanel also provides border, corner radius, and padding properties.", "SourcePath": "/LayoutPanel", "IsExperimental": true, @@ -2810,7 +2777,7 @@ ], "ApiNamespace": "Microsoft.UI.Xaml.Controls", "Subtitle": "A layout panel that arranges child elements in rows or columns and automatically wraps them onto new lines.", - "ImagePath": "ms-appx:///Assets/ControlImages/Placeholder.png", + "ImagePath": "ms-appx:///Assets/ControlImages/WrapPanel.png", "Description": "Use a WrapPanel to arrange child elements sequentially and move overflowing items to a new row or column. You can configure its orientation, spacing, padding, and whether the final item stretches to fill the remaining space.", "SourcePath": "/WrapPanel", "IsExperimental": true, diff --git a/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml b/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml deleted file mode 100644 index 05bb15932..000000000 --- a/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml.cs b/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml.cs deleted file mode 100644 index d1bf9b06e..000000000 --- a/WinUIGallery/Samples/FlowLayout/FlowLayoutPage.xaml.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Controls.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace WinUIGallery.ControlPages; - -public sealed partial class FlowLayoutPage : Page -{ - private readonly HashSet _realizedElements = []; - private bool _realizedCountUpdateQueued; - - public IReadOnlyList Items { get; } = Enumerable.Range(1, 500) - .Select(index => new FlowLayoutItem($"Item {index}")) - .ToList(); - - public FlowLayoutPage() - { - InitializeComponent(); - } - - private void OrientationButtons_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - if ((sender as RadioButtons)?.SelectedItem is RadioButton selectedItem && - Enum.TryParse(selectedItem.Tag?.ToString(), out Orientation orientation) && - FlowLayout1 is not null) - { - FlowLayout1.Orientation = orientation; - - if (FlowScrollViewer is not null) - { - bool isHorizontal = orientation == Orientation.Horizontal; - FlowScrollViewer.HorizontalScrollMode = isHorizontal ? ScrollMode.Disabled : ScrollMode.Enabled; - FlowScrollViewer.HorizontalScrollBarVisibility = isHorizontal - ? ScrollBarVisibility.Disabled - : ScrollBarVisibility.Auto; - FlowScrollViewer.VerticalScrollMode = isHorizontal ? ScrollMode.Enabled : ScrollMode.Disabled; - FlowScrollViewer.VerticalScrollBarVisibility = isHorizontal - ? ScrollBarVisibility.Auto - : ScrollBarVisibility.Disabled; - } - } - } - - private void LineAlignmentComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - if ((sender as ComboBox)?.SelectedItem is ComboBoxItem selectedItem && - Enum.TryParse(selectedItem.Tag?.ToString(), out FlowLayoutLineAlignment alignment) && - FlowLayout1 is not null) - { - FlowLayout1.LineAlignment = alignment; - } - } - - private void ItemSpacingSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) - { - if (FlowLayout1 is not null) - { - FlowLayout1.MinItemSpacing = e.NewValue; - } - } - - private void LineSpacingSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) - { - if (FlowLayout1 is not null) - { - FlowLayout1.LineSpacing = e.NewValue; - } - } - - private void FlowRepeater_ElementPrepared(ItemsRepeater sender, ItemsRepeaterElementPreparedEventArgs args) - { - _realizedElements.Add(args.Element); - QueueRealizedCountUpdate(); - } - - private void FlowRepeater_ElementClearing(ItemsRepeater sender, ItemsRepeaterElementClearingEventArgs args) - { - _realizedElements.Remove(args.Element); - QueueRealizedCountUpdate(); - } - - private void QueueRealizedCountUpdate() - { - if (_realizedCountUpdateQueued) - { - return; - } - - _realizedCountUpdateQueued = DispatcherQueue.TryEnqueue(() => - { - _realizedCountUpdateQueued = false; - RealizedCountText.Text = $"Realized elements: {_realizedElements.Count} of {Items.Count}"; - }); - } -} - -public sealed record FlowLayoutItem(string Label); diff --git a/WinUIGallery/Samples/FlowLayout/FlowLayoutVirtualization.txt b/WinUIGallery/Samples/ItemsRepeater/FlowLayoutVirtualization.txt similarity index 86% rename from WinUIGallery/Samples/FlowLayout/FlowLayoutVirtualization.txt rename to WinUIGallery/Samples/ItemsRepeater/FlowLayoutVirtualization.txt index 2d6994e74..a9f62b3d0 100644 --- a/WinUIGallery/Samples/FlowLayout/FlowLayoutVirtualization.txt +++ b/WinUIGallery/Samples/ItemsRepeater/FlowLayoutVirtualization.txt @@ -4,7 +4,7 @@ Use FlowLayout with ItemsRepeater to wrap and virtualize a large collection. - --- c# -public IReadOnlyList Items { get; } = Enumerable.Range(1, 500) +public IReadOnlyList FlowLayoutItems { get; } = Enumerable.Range(1, 500) .Select(index => new FlowLayoutItem($"Item {index}")) .ToList(); diff --git a/WinUIGallery/Samples/ItemsRepeater/ItemsRepeaterPage.xaml b/WinUIGallery/Samples/ItemsRepeater/ItemsRepeaterPage.xaml index 7d2d456fd..6e3b0b9ff 100644 --- a/WinUIGallery/Samples/ItemsRepeater/ItemsRepeaterPage.xaml +++ b/WinUIGallery/Samples/ItemsRepeater/ItemsRepeaterPage.xaml @@ -107,6 +107,21 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WinUIGallery/Samples/ItemsRepeater/ItemsRepeaterPage.xaml.cs b/WinUIGallery/Samples/ItemsRepeater/ItemsRepeaterPage.xaml.cs index eca86cc6c..836106f3b 100644 --- a/WinUIGallery/Samples/ItemsRepeater/ItemsRepeaterPage.xaml.cs +++ b/WinUIGallery/Samples/ItemsRepeater/ItemsRepeaterPage.xaml.cs @@ -5,6 +5,7 @@ using Microsoft.UI.Xaml.Automation; using Microsoft.UI.Xaml.Automation.Peers; using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; using Microsoft.UI.Xaml.Hosting; using Microsoft.UI.Xaml.Input; using System; @@ -31,6 +32,12 @@ public sealed partial class ItemsRepeaterPage : ItemsPageBase private Button? LastSelectedColorButton; private int PreviouslyFocusedAnimatedScrollRepeaterIndex = -1; + private readonly HashSet _realizedFlowLayoutElements = []; + private bool _realizedFlowLayoutCountUpdateQueued; + + public IReadOnlyList FlowLayoutItems { get; } = Enumerable.Range(1, 500) + .Select(index => new FlowLayoutItem($"Item {index}")) + .ToList(); public ItemsRepeaterPage() { @@ -250,6 +257,84 @@ private void LayoutBtn_SelectionChanged(object sender, SelectionChangedEventArgs } } + // ========================================================================== + // Virtualized wrapping collection with FlowLayout + // ========================================================================== + private void OrientationButtons_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if ((sender as RadioButtons)?.SelectedItem is RadioButton selectedItem && + Enum.TryParse(selectedItem.Tag?.ToString(), out Orientation orientation) && + FlowLayout1 is not null) + { + FlowLayout1.Orientation = orientation; + + if (FlowScrollViewer is not null) + { + bool isHorizontal = orientation == Orientation.Horizontal; + FlowScrollViewer.HorizontalScrollMode = isHorizontal ? ScrollMode.Disabled : ScrollMode.Enabled; + FlowScrollViewer.HorizontalScrollBarVisibility = isHorizontal + ? ScrollBarVisibility.Disabled + : ScrollBarVisibility.Auto; + FlowScrollViewer.VerticalScrollMode = isHorizontal ? ScrollMode.Enabled : ScrollMode.Disabled; + FlowScrollViewer.VerticalScrollBarVisibility = isHorizontal + ? ScrollBarVisibility.Auto + : ScrollBarVisibility.Disabled; + } + } + } + + private void LineAlignmentComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if ((sender as ComboBox)?.SelectedItem is ComboBoxItem selectedItem && + Enum.TryParse(selectedItem.Tag?.ToString(), out FlowLayoutLineAlignment alignment) && + FlowLayout1 is not null) + { + FlowLayout1.LineAlignment = alignment; + } + } + + private void ItemSpacingSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) + { + if (FlowLayout1 is not null) + { + FlowLayout1.MinItemSpacing = e.NewValue; + } + } + + private void LineSpacingSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) + { + if (FlowLayout1 is not null) + { + FlowLayout1.LineSpacing = e.NewValue; + } + } + + private void FlowRepeater_ElementPrepared(ItemsRepeater sender, ItemsRepeaterElementPreparedEventArgs args) + { + _realizedFlowLayoutElements.Add(args.Element); + QueueRealizedFlowLayoutCountUpdate(); + } + + private void FlowRepeater_ElementClearing(ItemsRepeater sender, ItemsRepeaterElementClearingEventArgs args) + { + _realizedFlowLayoutElements.Remove(args.Element); + QueueRealizedFlowLayoutCountUpdate(); + } + + private void QueueRealizedFlowLayoutCountUpdate() + { + if (_realizedFlowLayoutCountUpdateQueued) + { + return; + } + + _realizedFlowLayoutCountUpdateQueued = DispatcherQueue.TryEnqueue(() => + { + _realizedFlowLayoutCountUpdateQueued = false; + RealizedCountText.Text = $"Realized elements: {_realizedFlowLayoutElements.Count} of {FlowLayoutItems.Count}"; + }); + } + // ========================================================================== // Animated Scrolling ItemsRepeater with Content Sample // ========================================================================== @@ -445,6 +530,8 @@ public NestedCategory(string catName, ObservableCollection catItems) } } +public sealed record FlowLayoutItem(string Label); + public partial class MyDataTemplateSelector : DataTemplateSelector { diff --git a/WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml b/WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml index 5be769a8e..f1a4bd198 100644 --- a/WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml +++ b/WinUIGallery/Samples/LayoutPanel/LayoutPanelPage.xaml @@ -108,7 +108,7 @@ - + Date: Tue, 15 Sep 2026 12:53:24 +0200 Subject: [PATCH 3/3] Exclude PagerControl from Axe scan Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/WinUIGallery.UITests/Tests/AxeScanAllTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/WinUIGallery.UITests/Tests/AxeScanAllTests.cs b/tests/WinUIGallery.UITests/Tests/AxeScanAllTests.cs index a256ee83b..cdbe453d0 100644 --- a/tests/WinUIGallery.UITests/Tests/AxeScanAllTests.cs +++ b/tests/WinUIGallery.UITests/Tests/AxeScanAllTests.cs @@ -33,6 +33,8 @@ public class AxeScanAll : TestBase // parallel tree walk, before any rule filtering can take effect, so per-rule // exclusions are insufficient. "WebView2", + // The experimental PagerControl crashes the app when Axe.Windows walks its UIA tree. + "PagerControl", // MapControl is internally backed by a WebView2 hosting Azure Maps. The system // control has no public Dispose path, so its embedded WebView2 (and its UIA // Pane + Chromium RootWebArea) leaks into the process tree even after the page