-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
Currently the following test AddItemsToCarouselViewWorks is failing because the associated UI test Issue22417.xaml is failing to render correctly.
The CarouselViewController.cs is incorrectly getting it's ItemSize from the UICollectionViewController.CollectionView.Bounds before it is being laid out.
This causes it to just get set to some default screen size, which means that now all measure passes on the CarouselView just return this incorrect value
I was able to mostly fix the issue with the following code inside the CarouselViewHandler
I'm just not sure if this accounts for all the constraints checking that's done inside GetDesiredSizeFromHandler
.
Also this doesn't completely fix Issue22417.xaml . The view now renders the correct size, but now when you add an item and then call scrollto it fails to scroll and the new item doesn't render.
public override Size GetDesiredSize(double widthConstraint, double heightConstraint)
{
// I'm not sure if this solution is fully correct or if it properly accounts
// for all the constraints checks that GetDesiredSizeFromHandler takes into account
if (Primitives.Dimension.IsExplicitSet(widthConstraint) && Primitives.Dimension.IsExplicitSet(heightConstraint))
{
// If both width and height are explicitly set, we can use the base implementation
return base.GetDesiredSize(widthConstraint, heightConstraint);
}
var result = this.GetDesiredSizeFromHandler(widthConstraint, heightConstraint);
if (Primitives.Dimension.IsExplicitSet(widthConstraint))
{
// If width is explicitly set, we can use the width from the result
result = new Size(widthConstraint, result.Height);
}
else if (Primitives.Dimension.IsExplicitSet(heightConstraint))
{
// If height is explicitly set, we can use the height from the result
result = new Size(result.Width, heightConstraint);
}
return result;
}
public override void PlatformArrange(Rect rect)
{
(Controller.Layout as CarouselViewLayout)?.UpdateConstraints(rect.Size);
base.PlatformArrange(rect);
}
Also removing this code from the MapPeekAreaInsets because it is also causing the Contraints to get set incorrectly
(handler.Controller.Layout as CarouselViewLayout)?.UpdateConstraints(handler.PlatformView.Frame.Size);
Metadata
Metadata
Assignees
Labels
Type
Projects
Status