Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ double GetItemWidth()
if (double.IsInfinity(width))
return width;

itemWidth = (int)(width - Context?.ToPixels(VirtualView.PeekAreaInsets.Left) - Context?.ToPixels(VirtualView.PeekAreaInsets.Right) - Context?.ToPixels(listItemsLayout.ItemSpacing));
itemWidth = (int)(width - Context?.ToPixels(VirtualView.PeekAreaInsets.Left) - Context?.ToPixels(VirtualView.PeekAreaInsets.Right));
}

return itemWidth;
Expand All @@ -112,7 +112,7 @@ double GetItemHeight()
if (double.IsInfinity(height))
return height;

itemHeight = (int)(height - Context?.ToPixels(VirtualView.PeekAreaInsets.Top) - Context?.ToPixels(VirtualView.PeekAreaInsets.Bottom) - Context?.ToPixels(listItemsLayout.ItemSpacing));
itemHeight = (int)(height - Context?.ToPixels(VirtualView.PeekAreaInsets.Top) - Context?.ToPixels(VirtualView.PeekAreaInsets.Bottom));
}

return itemHeight;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue29609.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System.Collections.ObjectModel;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 29609, "ItemSpacing on CarouselView resizes items", PlatformAffected.Android)]
public class Issue29609 : ContentPage
{
Issue29609_ViewModel ViewModel;
public Issue29609()
{
ViewModel = new Issue29609_ViewModel();
BindingContext = ViewModel;
var stack = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center
};
var label = new Label
{
Text = "ItemSpacing on CarouselView resizes items",
AutomationId = "29609DescriptionLabel"
};
var carouselView = new CarouselView
{
BackgroundColor = Colors.Red,
AutomationId = "29609CarouselView",
HeightRequest = 400,
WidthRequest = 300,
ItemsSource = ViewModel.Items,
Loop = false,
ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal)
{
ItemSpacing = 50,
SnapPointsAlignment = SnapPointsAlignment.Center,
SnapPointsType = SnapPointsType.MandatorySingle
},
ItemTemplate = new DataTemplate(() =>
{
var grid = new Grid
{
BackgroundColor = Colors.Yellow
};

var label = new Label
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
label.SetBinding(Label.TextProperty, ".");

grid.Children.Add(label);
return grid;
})
};
stack.Children.Add(label);
stack.Children.Add(carouselView);
Content = stack;
}
}

public class Issue29609_ViewModel
{
public ObservableCollection<string> Items = new();

public Issue29609_ViewModel()
{
for (var i = 0; i < 5; i++)
{
Items.Add($"Item {i}");
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# if TEST_FAILS_ON_WINDOWS // ItemSpacing on CarouselView is not applied on Windows https://github.com/dotnet/maui/issues/29772
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue29609 : _IssuesUITest
{
public Issue29609(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "ItemSpacing on CarouselView resizes items";

[Test]
[Category(UITestCategories.CarouselView)]
public void VerifySpacingAffectsItemSize()
{
App.WaitForElement("29609DescriptionLabel");
VerifyScreenshot();
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading