I'm trying to render a collectionview inside a stacklayout using Xamarin.forms. But the collectionview isn't showing any data. I'm testing on ios using visual studio for mac.
I'm trying to learn to use the collectionview and Xamarin.Forms basics with ios
I've followed the most basic example from microsoft git repo for xamarin.forms found here: https://github.com/xamarin/xamarin-forms-samples/blob/master/UserInterface/CollectionViewDemos/CollectionViewDemos/Views/Layout/HorizontalListTextPage.xaml
I've copied the simple example to my own project in the Mainpage.xaml file but the collectionview data is only visible if I remove the outer Stacklayout like below
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:demo" x:Class="demo.MainPage">
<CollectionView ItemsLayout="{x:Static ListItemsLayout.HorizontalList}">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Baboon</x:String>
<x:String>Capuchin Monkey</x:String>
<x:String>Blue Monkey</x:String>
<x:String>Squirrel Monkey</x:String>
<x:String>Golden Lion Tamarin</x:String>
<x:String>Howler Monkey</x:String>
<x:String>Japanese Macaque</x:String>
<x:String>Mandrill</x:String>
<x:String>Proboscis Monkey</x:String>
<x:String>Red-shanked Douc</x:String>
<x:String>Gray-shanked Douc</x:String>
<x:String>Golden Snub-nosed Monkey</x:String>
<x:String>Black Snub-nosed Monkey</x:String>
<x:String>Tonkin Snub-nosed Monkey</x:String>
<x:String>Thomas's Langur</x:String>
<x:String>Purple-faced Langur</x:String>
<x:String>Gelada</x:String>
</x:Array>
</CollectionView.ItemsSource>
</CollectionView>
</ContentPage>
I have added Forms.SetFlags("CollectionView_Experimental"); to the appdelete
I would expected the data to visible even with the stacklayout present in my mainpage.xaml.
UPDATE If i set the height explicit the collectionview data is visible, but that is not done in any of the examples in this solution but in the example layouts i'm linking to they are not setting the height explicit, that goes for all the examples found here https://github.com/xamarin/xamarin-forms-samples/tree/master/UserInterface/CollectionViewDemos
and if i start example solution they everything is wokring as expected but if i copy the examples over to my own solution i need to set the height explicit.
UPDATE If the MainPage is wrapped in a navigationpage everything is working as expexcted
MainPage = new NavigationPage(new MainPage());
but with the default
MainPage = new MainPage()
nothing is rendred