forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix CarouselView SnapPointsType not working on Windows #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
5
commits into
main
Choose a base branch
from
copilot/fix-15
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8c6c660
Initial plan
Copilot e5ada46
Fix CarouselView snap points not working on Windows by adding propert…
Copilot 2b192a6
Add comprehensive tests for CarouselView snap points functionality
Copilot f760daa
Fix PropertyChanged event not triggering for CarouselView snap points…
Copilot a76625e
Fix CarouselView snap points not responding during scroll on Windows
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/Controls/tests/DeviceTests/Elements/CarouselView/CarouselViewSnapPointsTests.Windows.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.Maui.Controls; | ||
using Xunit; | ||
|
||
namespace Microsoft.Maui.DeviceTests | ||
{ | ||
public partial class CarouselViewSnapPointsTests | ||
{ | ||
// Windows-specific test to verify that the ScrollViewer properties are actually set | ||
[Fact] | ||
public async Task CarouselViewSnapPointsAreAppliedToScrollViewerOnWindows() | ||
{ | ||
SetupBuilder(); | ||
|
||
var carouselView = new CarouselView | ||
{ | ||
ItemsSource = new[] { "Item 1", "Item 2", "Item 3" }, | ||
ItemTemplate = new DataTemplate(() => new Label()) | ||
}; | ||
|
||
var handler = await CreateHandlerAsync(carouselView); | ||
|
||
// Allow time for the handler to initialize | ||
await Task.Delay(200); | ||
|
||
// Change the snap points type | ||
carouselView.ItemsLayout.SnapPointsType = SnapPointsType.Mandatory; | ||
|
||
// Wait for the property change to propagate | ||
await Task.Delay(100); | ||
|
||
// Verify the change was applied to the view model | ||
Assert.Equal(SnapPointsType.Mandatory, carouselView.ItemsLayout.SnapPointsType); | ||
|
||
// Change the snap points alignment | ||
carouselView.ItemsLayout.SnapPointsAlignment = SnapPointsAlignment.Start; | ||
|
||
// Wait for the property change to propagate | ||
await Task.Delay(100); | ||
|
||
// Verify the change was applied to the view model | ||
Assert.Equal(SnapPointsAlignment.Start, carouselView.ItemsLayout.SnapPointsAlignment); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PropertyChanged is never triggered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f760daa. The issue was that Windows handler was missing the MapItemsLayout method, so when ItemsLayout property changed, the PropertyChanged proxy wasn't updated. Added MapItemsLayout method and UpdateLayoutPropertyChangeProxy method to properly handle ItemsLayout changes and ensure PropertyChanged events trigger correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When scrolling the carouselview , the SnapPoint does not respond, it scrolls more than one item
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a76625e. The issue was that snap points were only being set during initial setup but not properly refreshed during the CarouselView lifecycle. Added snap points updates when ScrollViewer is found, when items change, and ensured proper Windows ScrollViewer configuration (disabled zoom mode, compatible scroll mode). This ensures snap points work correctly during scrolling and prevent scrolling past multiple items.