Skip to content
Open
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 @@ -151,8 +151,6 @@ _pixelSize is not null &&
{
_pixelSize = null;
}

_pixelSize = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ public static void MapFooterTemplate(StructuredItemsViewHandler<TItemsView> hand
}

public static void MapItemsLayout(StructuredItemsViewHandler<TItemsView> handler, StructuredItemsView itemsView)
=> (handler.PlatformView as IMauiRecyclerView<TItemsView>)?.UpdateLayoutManager();
{
if (handler.PlatformView is IMauiRecyclerView<TItemsView> recyclerView)
{
recyclerView.UpdateAdapter();
recyclerView.UpdateScrollingMode();
recyclerView.UpdateLayoutManager();
}
}

public static void MapItemSizingStrategy(StructuredItemsViewHandler<TItemsView> handler, StructuredItemsView itemsView)
=> (handler.PlatformView as IMauiRecyclerView<TItemsView>)?.UpdateAdapter();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue29192.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Collections.ObjectModel;

namespace Maui.Controls.Sample.Issues;
[Issue(IssueTracker.Github, 29192, "[Android] CollectionView MeasureFirstItem ItemSizingStrategy Not Applied in Horizontal Layouts", PlatformAffected.Android)]
public class Issue29192 : ContentPage
{
public Issue29192()
{
CollectionView collectionView = new CollectionView();

var layout = new Grid();
var bindingContext = new Issue29192ViewModel();

collectionView.BindingContext = bindingContext;
collectionView.AutomationId = "CollectionView";
collectionView.ItemSizingStrategy = ItemSizingStrategy.MeasureFirstItem;
collectionView.ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal);

collectionView.ItemTemplate = new DataTemplate(() =>
{
var label = new Label();
label.SetBinding(Label.TextProperty, ".");
return label;
});

// Set the ItemsSource binding
collectionView.SetBinding(CollectionView.ItemsSourceProperty, "Items");
layout.Children.Add(collectionView);

Content = layout;
}
}


public class Issue29192ViewModel
{
public ObservableCollection<string> Items { get; set; }

public Issue29192ViewModel()
{
Items = new ObservableCollection<string>
{
"Short text.",
"This is a long text; it should be wrapped to avoid truncation or overflow.",
"This is very long text."
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS // CollectionView MeasureFirstItem sizing not applied on Windows, iOS and macOS) https://github.com/dotnet/maui/issues/29130
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue29192 : _IssuesUITest
{
public override string Issue => "[Android] CollectionView MeasureFirstItem ItemSizingStrategy Not Applied in Horizontal Layouts";

public Issue29192(TestDevice device) : base(device) { }

[Test]
[Category(UITestCategories.CollectionView)]
public void ShouldMeasureFirstItemInHorizontalLayouts()
{
App.WaitForElement("CollectionView");
VerifyScreenshot();
}
}
#endif
Loading