IndicatorView with DataTemplate - improvements
Issues Fixed
Fixes https://github.com/dotnet/maui/issues/21980 Fixes https://github.com/dotnet/maui/issues/24739 Closes https://github.com/dotnet/maui/pull/24717
| Before | After |
|---|---|
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
@kubaflo Could you rebase to fix the conflicts? Thanks in advance.
@jsuarezruiz rebased and fixed conflicts
/rebase
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
@rmarinho I see, this is a screenshot from 2 months ago, I just reuploaded a new one :)
Unfortunately,, I cannot fix this problem: https://github.com/dotnet/maui/pull/24776#discussion_r1817845429, because I don't have Windows
/rebase
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
I double check and the test is crashing on Windows IndicatorViewShouldRenderCorrectly.
https://dev.azure.com/xamarin/public/_build/results?buildId=130815&view=ms.vss-test-web.build-test-results-tab&runId=3514041&resultId=100085&paneView=debug
I cannot fix it on Windows :/ https://github.com/dotnet/maui/pull/24776#issuecomment-2506036415
I double check and the test is crashing on Windows IndicatorViewShouldRenderCorrectly. https://dev.azure.com/xamarin/public/_build/results?buildId=130815&view=ms.vss-test-web.build-test-results-tab&runId=3514041&resultId=100085&paneView=debug
I cannot fix it on Windows :/ #24776 (comment)
oh sorry so many comments, let me give it a look .
/rebase
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/rebase
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/rebase
/azp run
I wonder if instead of setting the
WidthRequestandHeightRequestfor this one we can overrideMeasureOverrideand provide the proper measure values from that?For example, as a quick test I did this
#pragma warning disable RS0016 // Add public types and members to the declared API protected override Size MeasureOverride(double widthConstraint, double heightConstraint) #pragma warning restore RS0016 // Add public types and members to the declared API { var size = base.MeasureOverride(widthConstraint, heightConstraint); var width = templatedItemWidth.Value * Count + DefaultPadding * (Count - 1); var height = templatedItemHeight.Value; return new Size(width, height); }And that worked without having to set the Width/HeightReuqest
Or alternatively
Why don't we override
SizeThatFitson MauiPageControl ?
Thanks!
I tried on android, but when I change the item, it doesn t change the selected item of the carouselview, also if I click one on the indicator, sometimes it goes to the next item, other it doesn't.
Works fine on iOS
I've checked, and the issue happens when we have the same images in carousel view. It appears to be already existing bug. I've updated the sample in the UI test. Can you have a look if it works for you?
@rmarinho This is what happens on main, but I'd rather fix it in a separate PR
| Same images | Different images |
|---|---|
@rmarinho it happens because all of the items have a bindingContext="dotnet_bot.png", so
int GetIndexFromTemplatedCell(global::Android.Views.View view)
{
int itemIndex = -1;
if (view is ItemContentView templatedCell && ItemsViewAdapter != null)
{
var bContext = (templatedCell?.View as VisualElement)?.BindingContext;
itemIndex = ItemsViewAdapter.GetPositionForItem(bContext);
}
return itemIndex;
}
in CarouselViewOnScrollListener.cs returns the same index for all the elements