Xamarin Forms CollectionView not showing on iPhone but on Android and Android simulator

Az0th 1 Reputation point
2020-11-24T15:49:24.353+00:00

Hello guys,

I have a problem and a question regarding Xamarin.Forms and CollectionView. I implemented a CollectionView as a Main Menu and on Android it is working fine.
But on my iPhone it is not showing the CollectionView.
The ScrollView is showing I think because the LightBlue background is visible on my iPhone.

It is build for iOS 9 and Android 9.0 and with XCode 12.2.

Are there known issues with ObservableCollections, CollectionViews, some attributes or maybe someone can tell my what I did wrong.

This is how it looks on Android:

42167-image.png

This is my xaml code and C# code:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"  
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
             x:Class="FlyThePilotHelper.MainPage"  
             xmlns:local="clr-namespace:FlyThePilotHelper.ViewModels">  
  
    <ContentPage.BindingContext>  
        <local:MainPageViewModel/>  
    </ContentPage.BindingContext>  
 
    <ScrollView BackgroundColor="LightBlue">  
  
        <CollectionView Grid.Row="3" Grid.ColumnSpan="2" ItemsSource="{Binding AllMenuItems}"  
                        SelectionMode="Single"  
                        SelectedItem="{Binding SelectedMenuItem}"  
                        SelectionChangedCommand="{Binding SelectedMenuItemChangedCommand}">  
                  
                <CollectionView.ItemsLayout>  
                    <GridItemsLayout Orientation="Vertical" Span="2" />  
                </CollectionView.ItemsLayout>  
                  
                <CollectionView.ItemTemplate>  
                    <DataTemplate>  
                        <StackLayout Padding="10,10">  
                        <Frame CornerRadius="50">  
                            <Label x:Name="label1" Text="{Binding .}" FontSize="Title" WidthRequest="100"  
                                   VerticalTextAlignment="Center" HorizontalTextAlignment="Center"  
                                   HeightRequest="{Binding Width, Source={x:Reference label1}}"/>  
                             </Frame>  
                        </StackLayout>  
                    </DataTemplate>  
                </CollectionView.ItemTemplate>  
            </CollectionView>  
    </ScrollView>  
</ContentPage>  


            AllMenuItems = new ObservableCollection<string>  
            {  
                "Unit Conversions",  
                "Procedures",  
                "Wind Calculations",  
                "Fuel Calculations"  
            };  
        }  
  
          
        string selectedMenuItem;  
        public string SelectedMenuItem  
        {  
            get => selectedMenuItem;  
            set  
            {  
                selectedMenuItem = value;  
  
                var args = new PropertyChangedEventArgs(nameof(SelectedMenuItem));  
  
                PropertyChanged?.Invoke(this, args);  
            }  
        }  
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2020-11-25T09:04:36.133+00:00

    Hello,

    Welcome to Microsoft Q&A!

    I tried your code in iOS , however it works as expected on my side .

    42661-capture.png

    Could I know what's the version of Xamarin.Forms are you using?

    Thank you.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Az0th 1 Reputation point
    2020-11-25T09:23:13.1+00:00

    Oooh thats nice.
    I use:

    Microsoft Visual Studio Community 2019
    Version 16.8.2

    Xamarin 16.8.000.255 (d16-8@d002176)
    Visual Studio-Erweiterung, um Entwicklung für Xamarin.iOS und Xamarin.Android zu ermöglichen.

    Xamarin Designer 16.8.0.507 (remotes/origin/d16-8@e87b24884)
    Visual Studio-Erweiterung zum Aktivieren der Xamarin Designer-Tools in Visual Studio.

    Xamarin Templates 16.8.112 (86385a3)
    Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

    Xamarin.Android SDK 11.1.0.17 (d16-8/c0e2b8e)
    Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: be2226b
    Java.Interop: xamarin/java.interop/d16-8@79d9533
    ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000
    SQLite: xamarin/sqlite/3.32.1@1a3276b
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc

    Xamarin.iOS and Xamarin.Mac SDK 14.4.1.3 (e30c41de3)
    Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

    0 comments No comments

  3. Az0th 1 Reputation point
    2020-11-25T09:54:57.17+00:00

    Addition:
    It is build with Appcenter.ms
    with
    Xamarin.iOS 14.4 Mono 6.12
    and XCode 12.2


  4. Az0th 1 Reputation point
    2020-11-26T09:32:29.847+00:00

    Yes I can.
    This is the link to that repo:

    https://github.com/Az0th/ForumTest.git

    Can the issue come because of build settings like "Link All" or something like that?
    Or because of the iOS version target?
    It is set to iOS 9.0 at the moment.