Xamarin.forms: [Bug] [Android] ContentView in CollectionView does not display anything on Android

Created on 8 Jun 2019  路  3Comments  路  Source: xamarin/Xamarin.Forms

Description

Using a CollectionView where the ItemTemplate has a ContentView with a Label does not display anything in the CollectionView. This seems to work on iOS.

Steps to Reproduce

  1. Create a CollectionView
  2. Set ItemTemplate:
<CollectionView x:Name="colv">
    <CollectionView.ItemTemplate>
         <DataTemplate>
              <ContentView>
                   <Label Text="{Binding Text}"></Label>
              </ContentView>
         </DataTemplate>
    </CollectionView.ItemTemplate>
</CollectionView>
  1. Create a class:
public class T
{
    public string Text { get; set; }
}
  1. Create List and set ItemSource of CollectionView
List<T> cc = new List<T>();
public MainPage()
{
    InitializeComponent();

    for(int i = 0; i < 10; i++)
    {
        cc.Add(new T { Text = "p" + i });
    }
    colv.ItemsSource = cc;
}

Expected Behavior

Show the items in the collectionview

Actual Behavior

Nothing is shown in the collectionview

Basic Information

  • Version with issue: 4.0.0.425677
  • Last known good version: -
  • IDE: VS Mac, VS
  • Platform Target Frameworks:

    • Android: 9.0

  • Android Support Library Version:
  • Affected Devices: tested with Motorola G6 Plus but seems to not work on any android device.

Reproduction Link

https://github.com/SergejDK/XFCollectionViewContentView

collectionview Android unverified bug

Most helpful comment

This is fixed in 4.1.0.496342-pre2.

All 3 comments

This is fixed in 4.1.0.496342-pre2.

Thanks @hartez ! Works like a charm!

Was this page helpful?
0 / 5 - 0 ratings