Skip to content

[Windows] Fix CarouselView position changes without animation - #40727

Merged
kubaflo merged 2 commits into
dotnet:candidate/11.0.1xx-sr3from
Shalini-Ashokan:fix-33543
Dec 1, 2026
Merged

kubaflo merged 2 commits into
dotnet:candidate/11.0.1xx-sr3from
Shalini-Ashokan:fix-33543

Conversation

@Shalini-Ashokan

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

On Windows, changing a bound CarouselView.Position may leave the carousel showing the previous item. The issue occurs when scrolling is not animated, including when swipe scrolling is disabled.

Root Cause

The scroll helper inferred direction from the ScrollViewer’s horizontal scroll mode. With swiping disabled, that mode can be disabled even for a horizontal carousel, so the helper calculated the offset on the wrong axis.

Description of Change

Determine direction from the realized ItemsStackPanel orientation, falling back to the existing check when the panel is unavailable. Added Windows regression coverage for binding updates, both orientations, animation and swipe settings, and peek area insets.

Validated the behavior in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #33543

Output ScreenShot

Before After
33543-BeforeFix.mp4
33543-AfterFix.mov

@github-actions

This comment has been minimized.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 27, 2026
@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot 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.

Expert Review — 1 finding

Reviewed commit f84bb31.

See inline comments for details.

kubaflo added a commit that referenced this pull request Nov 28, 2026
…40767)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Correct the Windows Shell flyout-clipping device test's native-layout
prerequisites without changing product behavior, skipping tests, adding
retries, or weakening its regression assertions.

Stop retaining the first `DataTemplate` instance. WinUI can prepare
template instances outside the live flyout or replace them. A handler
alone does not establish visual-tree membership or completed
arrangement. Select the loaded, positively arranged flyout item from the
actual Shell visual tree, then run the unchanged non-null clip and exact
rounded-width assertions. The readiness wait does not wait for the
assertion to become true.

Existing-fix search covered open and recently merged PRs. #40717
concerns custom TitleBar overlap, not flyout-template selection. #40692
addresses a different ContentButton reparenting test, and #40727
addresses Windows CarouselView position updates; neither is duplicated
here.

#### Validation and scope correction

- **Baseline red = main 1703707**, head `34964bfc72`. Shell fails in
both packaged attempts and the second unpackaged attempt; the first
unpackaged attempt passes. Raw first-attempt logs: 787/788;
second-attempt logs: 962/960. Both Windows Shell jobs also fail in
migration PR #40661 build 1703676 (logs 757/766).
- **Fix = PR CI 1703831** at `1e894622fe`: Windows Shell category **92
passed, 0 failed, 0 skipped in each mode**, logs
[757](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1703831/logs/757?api-version=7.1)
and
[758](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1703831/logs/758?api-version=7.1).
The unchanged Shell patch compiled and executed on Windows in that CI
run.
- The initial commit also attached the ContentButton replacement test to
a native window. **CI disproved that attempted fix**: build 1703831 Core
logs 621/625 still report expected frame `{X=5 Y=5 Width=170
Height=80}`, actual zero. That Button change has been reverted in a
normal follow-up commit; the net PR diff now contains only
`ShellTests.Windows.cs`.
- Static tracing of the Button path confirms `SetVirtualView(second)`
updates the panel's `CrossPlatformLayout`, maps the expected replacement
native content, and measures its requested size.
`ContentButtonLayout.Arrange` would assign the presented content's
managed frame through `StubBase.Arrange`; the current failure logs do
not prove why that arrange path is not reflected in the frame. No
speculative timing workaround or product fix is included.
- `git diff --exit-code 34964bf --
src/Core/tests/DeviceTests/Handlers/ContentButton/ContentButtonWindowsTests.Windows.cs`
— **passed**, proving the Button file is restored exactly to the
baseline.
- `git diff --check` — **passed**.
- Initial local `dotnet build Microsoft.Maui.BuildTasks.slnf -v:q` —
**passed**. Initial `dotnet format whitespace Microsoft.Maui.sln
--no-restore --include
src/Core/tests/DeviceTests/Handlers/ContentButton/ContentButtonWindowsTests.Windows.cs
src/Controls/tests/DeviceTests/Elements/Shell/ShellTests.Windows.cs
--verbosity quiet` — **passed**.
- Initial Windows cross-host build attempts on macOS were blocked by
native tooling: Core's Windows-only build reached `MakePri.exe` and
failed with exec format error; Controls' fallback with
`AppxGeneratePriEnabled=false` reached the native WinUI XAML compiler
and failed without `output.json`. No local Windows compilation or
runtime success is claimed.
- Revert/restore runtime verification **not run (no Windows host)**. The
Button source restoration is mechanically verified; updated PR CI is
requested separately.

CarouselView native-centering and HybridWebView coexistence failures did
not repeat across baseline attempts and passed the migration PR
comparison, so they remain unchanged. The recurrent NavigationPage crash
had `SettingTitleIconImageSourceDoesntCrash` in flight, but no dump and
an unproven cause; it is neither patched speculatively nor classified as
infrastructure. PageTransitions is outside this PR's scope.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Addresses the recurring Windows Shell flyout-clipping device-test
failure in builds 1703707 and 1703676. No separate tracking issue;
preserves regression coverage for #19542. The ContentButton replacement
failure remains unresolved and is no longer changed by this PR.

### Let AI finish this PR

- [ ] **Let the MAUI agent address review feedback and fix remaining
issues on this PR.** Maintainers still decide whether it is merged. For
PRs from forks, the agent opens a follow-up PR that keeps your commits.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot 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.

Expert Review — No more findings

Reviewed commit f84bb31.

@github-actions

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it label Dec 1, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the s/autopilot-testing MAUI Autopilot: relevant UI/device tests are being selected or run label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Selected Tests

Result NOT QUEUED Platforms Windows Tests 8 UI, 2 device Commit f84bb316


🧪 Test selection — click to expand
Suite Result Selected Build
UI tests ❌ not queued 8 of 77 categories —
Device tests ❌ not queued 2 of 105 units —
🧪 UI tests — CarouselView, CollectionView1, CollectionView2, CollectionView3 +4 on Windows

❌ Could not queue maui-pr-uitests: Azure Pipelines did not start maui-pr-uitests for the dispatch branch run-tests/pr40727-46549075721 within 10 minutes. Comment /review run-tests again, or use /azp run maui-pr-uitests for the full suite.

GPT-6.2 Sol: Run Windows CarouselView and CollectionView UI tests for the scroll-axis fix.
MAI Code 2: Windows CarouselView and CollectionView scrolling fix; run their UI tests on Windows.

🧪 Running — 8 categories on Windows

Platform Categories
Windows CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7
🧪 Device tests — Controls.CarouselView, Controls.CollectionView on Windows

❌ Could not queue maui-pr-devicetests: Azure Pipelines did not start maui-pr-devicetests for the dispatch branch run-devicetests/pr40727-46549075721 within 10 minutes. Comment /review run-tests again, or use /azp run maui-pr-devicetests for the full suite.

GPT-6.2 Sol: Run Windows CarouselView and CollectionView device tests for the new bound-position regression and the shared scrolling path.
MAI Code 2: Windows CarouselView position fix with regression coverage; run CarouselView and CollectionView device tests on Windows.

🧪 Running — 2 categories on Windows

Platform Categories
Windows Controls.CarouselView, Controls.CollectionView
⏭️ Skipped — what neither suite runs

UI tests — 69 categories, 3 platforms

Platforms not run: Android, iOS, MacCatalyst

Categories not run: Accessibility, ActionSheet, ActivityIndicator, Animation, AppLinks, Border, BoxView, Brush, Button, Cells, CheckBox, ContextActions, CustomRenderers, DatePicker, Dispatcher, DisplayAlert, DisplayPrompt, DragAndDrop, Entry, Editor, Effects, Essentials, FlyoutPage, Focus, Fonts, Frame, Gestures, GraphicsView, Image, ImageButton, IndicatorView, InputTransparent, IsEnabled, IsVisible, Label, Layout, Lifecycle, ManualReview, Maps, Navigation, Page, Performance, Picker, ProgressBar, RadioButton, RefreshView, SafeAreaEdges, Shadow, ScrollView, SearchBar, Shape, Slider, SoftInput, Stepper, Switch, SwipeView, Shell1, Shell2, TabbedPage, TableView, TimePicker, TitleView, ToolbarItem, Triggers, ViewBaseTests, VisualStateManager, Window, WebView, Material3

Each skipped platform and category is listed as a maui-pr-uitests (skipped) … status on this commit. Use /azp run maui-pr-uitests for the full suite.

Device tests — 103 categories, 3 platforms

Platforms not run: Android, iOS, MacCatalyst

Categories not run: Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CheckBox, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay, Graphics, Essentials, BlazorWebView

Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.

🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)

UI tests

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.2 Sol MAI Code 2
Android — —
iOS — —
MacCatalyst — —
Windows CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7 CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7

GPT-6.2 Sol — Run Windows CarouselView and CollectionView UI tests for the scroll-axis fix.

  • ScrollHelpers.cs uses panel orientation for CarouselView position changes.
  • CollectionView uses the same helper for ScrollTo alignment.
  • No other platforms or UI categories are affected.

MAI Code 2 — Windows CarouselView and CollectionView scrolling fix; run their UI tests on Windows.

  • ScrollHelpers.cs is Windows-only and changes how CollectionView and CarouselView infer scroll direction.
  • Run CarouselView UI tests on Windows for bound Position changes, including swiping and animation scenarios.
  • Run CollectionView UI coverage because the shared Windows scroll helper also adjusts collection scrolling.
  • Exclude Android, iOS, and MacCatalyst because no non-Windows implementation changed.

Device tests

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.2 Sol MAI Code 2
Android — —
iOS — —
MacCatalyst — —
Windows Controls.CarouselView, Controls.CollectionView Controls.CarouselView, Controls.CollectionView

GPT-6.2 Sol — Run Windows CarouselView and CollectionView device tests for the new bound-position regression and the shared scrolling path.

  • CarouselViewTests.Windows.cs adds bound-position coverage across orientations, animation, swiping, and peek insets.
  • ScrollHelpers.cs also changes CollectionView ScrollTo alignment.
  • No Core code or non-Windows paths changed.

MAI Code 2 — Windows CarouselView position fix with regression coverage; run CarouselView and CollectionView device tests on Windows.

  • The modified Windows CollectionView scroll helper affects CarouselView and CollectionView scroll positioning.
  • The added Windows device test directly exercises bound CarouselView Position updates.
  • Select Controls.CarouselView and Controls.CollectionView for the shared controls implementation and regression surface.
  • Exclude non-Windows platforms because the product change and added test are Windows-specific.

Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.

@github-actions github-actions Bot added s/autopilot-waiting-for-maintainer-review MAUI Autopilot finished: expert review clean and tests passed; waiting for maintainer review and removed s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it s/autopilot-testing MAUI Autopilot: relevant UI/device tests are being selected or run labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

MAUI Autopilot — Ready for maintainer review

Results
Expert review No more findings on f84bb31
Tests ⚠️ Could not run; re-run /review run-tests when CI is available
Review threads None

@Shalini-Ashokan Shalini-Ashokan changed the title [WIP][Windows] Fix CarouselView position changes without animation [Windows] Fix CarouselView position changes without animation Dec 1, 2026
@sheiksyedm
sheiksyedm marked this pull request as ready for review December 1, 2026 14:24
@kubaflo
kubaflo changed the base branch from net11 to candidate/11.0.1xx-sr3 December 1, 2026 22:32
@kubaflo
kubaflo merged commit e8ccac1 into dotnet:candidate/11.0.1xx-sr3 Dec 1, 2026
145 of 148 checks passed

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — f84bb316 Deployed Nov 27, 2026 by Shalini-Ashokan via conclusion #3418
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows s/autopilot-waiting-for-maintainer-review MAUI Autopilot finished: expert review clean and tests passed; waiting for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] CarouselView.Position binding reverts when IsScrollAnimated=True and Windows "Animation effects" is disabled

3 participants