-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
Setting the IsSwipeEnabled property of a CarouselView to False on the Windows platform prevents the visual switching of views when the Position property is updated programmatically (e.g., via TwoWay binding or ScrollTo). The view content fails to scroll or switch to the new position, even though the Position property itself and related events (like PositionChanged) might update correctly. This issue does not occur on the Android platform.
Expected Behavior:
Setting IsSwipeEnabled to False should only disable user touch or mouse swipe gestures for changing pages. Programmatically changing the CarouselView's position (e.g., by updating the bound Position property or calling the ScrollTo method) should still be able to visually scroll or instantly display the content at the new position.
Actual Behavior:
When IsSwipeEnabled is set to False, the visual content of the CarouselView does not switch when the CarouselView.Position property is updated via binding (or other programmatic means, like clicking a bound button that changes the ViewModel property). The CarouselView remains visually stuck on the initial page, even though the logical value of the Position property has changed (as evidenced by logs and the PositionChanged event).
On the Android platform, setting IsSwipeEnabled to False only disables user swiping, and programmatic changes to Position or calls to ScrollTo still correctly switch the views.
Related Issue:
This issue might be related to the navigation instability and binding loop observed on the Windows platform when using TwoWay binding on the Position property (#29215 ). This problem seems to prevent the programmatic animation/visual focus change that is key to making TwoWay binding (or any programmatic position update) work correctly.
Steps to Reproduce
- Clone the provided minimal reproducible sample repository (in this MRE,
IsSwipeEnabledis pre-set toFalse): [https://github.com/snowcatliy/MAUI_MRE_CarouselView_IsSwipeEnabledBug_Windows] - Build and run the project on the Windows platform.
- Click the "Page 2" button.
- Observe the visual behavior of the
CarouselView(should remain stuck on Page 1 visually) and check the output console logs (thePositionproperty should have updated to 1). - Click the "Page 1" button.
- Again, observe the visual behavior (should still remain stuck on the current page) and check the output console logs (the
Positionproperty should have updated to 0). - (Optional) Repeat steps 2-6 on the Android platform and observe the correct visual behavior.
Relevant log output:
Console output after clicking the "Page 1" button when the CarouselView is on Page 2:
Windows:
[ViewModel] TabSelectedCommand triggered with index: 0
[ViewModel] CurrentTabIndex changed to: 0
[Page] CarouselView Position changed to: 0, Previous: 1, ViewModel CurrentTabIndex: 0
Android:
[0:] [ViewModel] TabSelectedCommand triggered with index: 0
[0:] [ViewModel] CurrentTabIndex changed to: 0
[0:] [Page] CarouselView Position changed to: 0, Previous: 1, ViewModel CurrentTabIndex: 0
[0:] [ViewModel] CurrentTabIndex changed to: 1
[0:] [Page] CarouselView Position changed to: 1, Previous: 0, ViewModel CurrentTabIndex: 1
[0:] [ViewModel] CurrentTabIndex changed to: 0
[0:] [Page] CarouselView Position changed to: 0, Previous: 1, ViewModel CurrentTabIndex: 0
Visual Evidence:
Windows Behavior GIF (IsSwipeEnabled=False):
Android Behavior GIF (IsSwipeEnabled=False - Working fine):
Link to public reproduction project repository
https://github.com/snowcatliy/MAUI_MRE_CarouselView_IsSwipeEnabledBug_Windows
Version with bug
9.0.60 SR6
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
No response
Did you find any workaround?
No response

