Skip to content

feat: ItemsRepeater update - #22387

Closed
MartinZikmund wants to merge 13 commits into
masterfrom
dev/mazi/items-repeater-winui
Closed

MartinZikmund wants to merge 13 commits into
masterfrom
dev/mazi/items-repeater-winui

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Jan 19, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #21136

PR Type:

What is the current behavior? 🤔

What is the new behavior? 🚀

PR Checklist ✅

Please check if your PR fulfills the following requirements:

Other information ℹ️

Copilot AI review requested due to automatic review settings January 19, 2026 10:23
@MartinZikmund
MartinZikmund marked this pull request as draft January 19, 2026 10:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a major update to the ItemsRepeater control infrastructure, synchronizing with WinUI 3 release 1.8.4. The changes introduce a new transition system and LinedFlowLayout.

Changes:

  • Replaces deprecated AnimationManager with new TransitionManager for handling item transitions
  • Adds LinedFlowLayout, a new layout that arranges items into lines with horizontal flow
  • Implements ItemCollectionTransitionProvider infrastructure for customizable item animations
  • Adds supporting classes for aspect ratio tracking and transition events

Reviewed changes

Copilot reviewed 27 out of 36 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
TransitionManager.cs New transition manager replacing AnimationManager
ItemsRepeater.cs Updated to use TransitionManager, deprecated Animator property
LinedFlowLayout*.cs New layout implementation with properties and aspect ratio tracking
ItemCollectionTransition*.cs New transition provider infrastructure classes
ViewManager.cs Updated to support recycling without owner
VirtualizationInfo.cs Added MustClearDataContext property and debug helpers
ViewportManager*.cs Added ResetLayoutRealizationWindowCacheBuffer method
SelectionModel.cs Fixed range selection for single-item ranges
ElementManager.cs Made several methods public, added data index lookup
Layout.cs Added CreateDefaultItemTransitionProvider virtual method
Generated/*.cs Updated generated code to skip implemented declarations
RuntimeTests/* Added comprehensive tests for new functionality

ResetCacheBuffer(false /*registerCacheBuildWork*/);
}

void ResetCacheBuffer(bool registerCacheBuildWork = true)

Copilot AI Jan 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method signature has inconsistent spacing in the boolean parameter default value. The parameter should be formatted as registerCacheBuildWork = true for consistency, with a space before the equals sign.

Copilot uses AI. Check for mistakes.
Comment on lines +6 to 8
#if false
[global::Uno.NotImplemented]
#endif

Copilot AI Jan 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional directive pattern #if false followed by [global::Uno.NotImplemented] is being used for types that are now implemented. Since these types have actual implementations in the source files, the generated stubs should either be removed or the conditional compilation symbol should be updated to reflect that these are now implemented across all platforms.

Suggested change
#if false
[global::Uno.NotImplemented]
#endif

Copilot uses AI. Check for mistakes.
double startX = 0;
double extraSpace = availableWidth - totalDesiredWidth - (itemCount - 1) * minItemSpacing;

if (stretch == LinedFlowLayoutItemsStretch.Fill && extraSpace > 0)

Copilot AI Jan 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Division by zero risk: The method divides by itemCount - 1 when calculating spacing. If itemCount is 1, this will cause a division by zero exception. Although the condition if (itemCount > 1) guards the SpaceBetween case, the Fill stretch calculation at line 458 is not guarded and will fail when itemCount is 1.

Suggested change
if (stretch == LinedFlowLayoutItemsStretch.Fill && extraSpace > 0)
if (stretch == LinedFlowLayoutItemsStretch.Fill && extraSpace > 0 && itemCount > 1)

Copilot uses AI. Check for mistakes.
int currentWeight = _aspectRatios[i].Weight;
int currentIndex = StartIndex + i;

if (currentWeight == weight || (currentIndex >= firstItemIndex && currentIndex <= lastItemIndex))

Copilot AI Jan 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic condition appears incorrect. The condition uses OR (||) when it should likely use AND (&&). The current logic includes weights in totals if EITHER the weight matches OR the index is in range, but it should only include weights that are in the specified range. This should be currentWeight == weight && currentIndex >= firstItemIndex && currentIndex <= lastItemIndex.

Suggested change
if (currentWeight == weight || (currentIndex >= firstItemIndex && currentIndex <= lastItemIndex))
if (currentWeight == weight && currentIndex >= firstItemIndex && currentIndex <= lastItemIndex)

Copilot uses AI. Check for mistakes.
@unodevops

Copy link
Copy Markdown
Contributor

@morning4coffe-dev morning4coffe-dev mentioned this pull request Jan 19, 2026
2 tasks done
Copilot AI review requested due to automatic review settings January 21, 2026 14:36
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/items-repeater-winui branch from 29426b2 to aa30dd5 Compare January 21, 2026 14:36
MartinZikmund and others added 13 commits January 21, 2026 15:36
Phase 1 of ItemsRepeater WinUI update (winui3/release/1.8.4).

VirtualizationInfo.cs:
- Add MustClearDataContext property
- Add SetLogItemIndex/GetLogItemIndex debug methods

ElementManager.cs:
- Add GetFirstRealizedDataIndex property
- Add IsLayoutBoundsForRealizedIndexSet method
- Make Insert, ClearRealizedRange, GetRealizedRangeIndexFromDataIndex public
- Uncomment and enable GetElementDataIndex method

_Tracing.cs:
- Add s_IsDebugOutputEnabled, s_IsVerboseDebugOutputEnabled flags
- Add ITEMSREPEATER_TRACE_INFO_DBG, ITEMSREPEATER_TRACE_VERBOSE_DBG macros
- Add REPEATER_TRACE_VERBOSE method

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Phase 2 of ItemsRepeater WinUI update (winui3/release/1.8.4).

Implements the new transition system that replaces AnimationManager:

ItemCollectionTransition.cs:
- Represents a single transition with Operation, Triggers, OldBounds, NewBounds
- Supports Add, Remove, and Move operations
- Start() method returns ItemCollectionTransitionProgress for tracking

ItemCollectionTransitionProgress.cs:
- Tracks transition progress and completion
- Complete() method notifies provider of completion

ItemCollectionTransitionCompletedEventArgs.cs:
- Event args for TransitionCompleted event

ItemCollectionTransitionProvider.cs:
- Base class for custom transition providers
- QueueTransition batches transitions
- Uses CompositionTarget.Rendering for batched execution
- Keep-alive timers ensure transitions complete properly

TransitionManager.cs:
- Internal class replacing AnimationManager
- Bridges ItemsRepeater with ItemCollectionTransitionProvider
- Handles collection change and layout transition triggers

Note: Generated files have been modified to provide implementations.
These should be converted to proper non-generated files when the
Uno generator is run.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Replace AnimationManager with TransitionManager for new transition system
- Add ItemTransitionProvider property support via Generated file
- Implement GetDefaultLayout() and GetEffectiveLayout() pattern
- Add OnTransitionProviderChanged handler
- Update ViewManager to use TransitionManager
- Mark Animator property as obsolete (backwards compatibility preserved)
- Add m_ownsTransitionProvider and m_wasLayoutChangedCalled fields

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add RecycleWithoutOwner method to ViewManager for element recycling
  without setting owner (used during collection changes)
- Add ResetLayoutRealizationWindowCacheBuffer to ViewportManager base class
- Implement ResetLayoutRealizationWindowCacheBuffer in ViewportManagerWithPlatformFeatures
  which resets cache buffer without registering cache build work
- Update ResetCacheBuffer to accept optional registerCacheBuildWork parameter
- Update MUX reference tags to winui3/release/1.8.4

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ovider

- Implement CreateDefaultItemTransitionProvider virtual method in Layout source
- Method returns null by default; derived classes (e.g., LinedFlowLayout) can override
- Skip generated stub via comment in Generated file
- Update MUX reference tag to winui3/release/1.8.4

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ce files

The implementations for ItemCollectionTransition types were incorrectly
placed in Generated files. This moves them to proper source files:
- ItemCollectionTransition.cs
- ItemCollectionTransitionCompletedEventArgs.cs
- ItemCollectionTransitionProgress.cs
- ItemCollectionTransitionProvider.cs

Also adds ItemTransitionProvider dependency property to
ItemsRepeater.Properties.cs.

Generated files now only contain skip comments, following the Uno pattern
of using partial classes with implementations in source files.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add optimization in SelectRangeImpl to use SelectAt/DeselectAt directly
when start and end indices are equal, avoiding unnecessary tree traversal.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add Given_ItemCollectionTransitionProvider tests for new transition system
- Add Given_ItemsRepeater_Api tests for core ItemsRepeater functionality
- Fix obsolete warnings in existing tests using deprecated Animator property

Tests ported from WinUI tag winui3/release/1.8.4.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Port LinedFlowLayout from WinUI3 release/1.8.4. This adds:
- LinedFlowLayout.cs - main layout implementation
- LinedFlowLayout.Properties.cs - dependency properties
- LinedFlowLayoutItemAspectRatios.cs - aspect ratio storage
- LinedFlowLayoutItemsInfoRequestedEventArgs.cs - event args
- LinedFlowLayoutItemCollectionTransitionProvider.cs - transition animations

Update Generated files to skip already-declared members.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Skip two tests that need more investigation:
- When_TransitionProvider_TracksCalls: TransitionManager timing issue
- When_NestedRepeater_WithDataTemplate: Scroll offset precision varies

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Port LinedFlowLayoutTests.cs from WinUI to verify default property values.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…WinUI

Port ItemCollectionTransitionProviderTests.cs and helper class
ItemCollectionTransitionProviderDerived.cs from WinUI.

Note: Test is ignored in WinUI (Task 35797826) due to timing issues.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 45 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/Uno.UI/UI/Xaml/Controls/Repeater/ItemsRepeater.cs:964

  • The OnAnimatorChanged method is marked as obsolete but still contains complex logic (lines 955-964) that references SharedHelpers.IsRS5OrHigher(). Since this method is deprecated and the AnimationManager has been replaced with TransitionManager, this method should be simplified to just log a warning or do nothing, as indicated by the comment on line 952-954.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +3
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// ItemsRepeater.cpp, commit 3f3e328
// ItemsRepeater.cpp, tag winui3/release/1.8.4

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message format does not follow the Conventional Commits specification required by the repository. The title should start with a lowercase type (e.g., 'feat:', 'fix:') followed by a lowercase description. The current title uses title case: "feat: ItemsRepeater update" should be "feat: itemsrepeater update" or more specifically describe what feature is being added.

Copilot generated this review using guidance from organization custom instructions.
Comment on lines +707 to +720
private void InvalidateLayout(bool forceRelayout = true, bool resetItemsInfo = false, bool invalidateMeasure = true)
{
_forceRelayout |= forceRelayout;

if (resetItemsInfo)
{
ResetItemsInfo();
}

if (invalidateMeasure)
{
InvalidateMeasure();
}
}

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The InvalidateLayout method has a default parameter value of 'true' for 'invalidateMeasure' but this parameter is named inconsistently. The parameter is called 'invalidateMeasure' but it calls the method 'InvalidateMeasure()'. Consider renaming to 'shouldInvalidateMeasure' for clarity.

Copilot uses AI. Check for mistakes.
Comment on lines +114 to +118
public event TypedEventHandler<LinedFlowLayout, object> ItemsUnlocked
{
add => _itemsUnlocked += value;
remove => _itemsUnlocked -= value;
}

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the LinedFlowLayout.Properties.cs file, the ItemsUnlocked event uses TypedEventHandler with 'object' as the event args type (line 114). This is inconsistent with typical WinUI patterns where event args should be a specific EventArgs-derived type. Consider creating a proper LinedFlowLayoutItemsUnlockedEventArgs class for better type safety and extensibility.

Copilot uses AI. Check for mistakes.
@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days.

@github-actions github-actions Bot added the stale This item has been marked as stale and will be closed if there is no activity. label Mar 23, 2026
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions Bot closed this Apr 2, 2026
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 30, 2026
@MartinZikmund MartinZikmund removed the stale This item has been marked as stale and will be closed if there is no activity. label Jun 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update ItemsRepeater and its layouts

3 participants