question

Az0th-9601 avatar image
0 Votes"
Az0th-9601 asked ·

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

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);
             }
         }


dotnet-xamarinformsdotnet-xamarinforms-xaml
image.png (47.5 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ColeXia-MSFT avatar image
0 Votes"
ColeXia-MSFT answered ·

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.





capture.png (87.5 KiB)
·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Az0th-9601 avatar image
0 Votes"
Az0th-9601 answered ·

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.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Az0th-9601 avatar image
0 Votes"
Az0th-9601 answered ·

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

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ok , it seems everything is up to date , would you mind to share a basic , minimal project to github so that i can test on my side ?

0 Votes 0 ·
Az0th-9601 avatar image
0 Votes"
Az0th-9601 answered ·

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.

· 6 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have another information.
I got Xamarin Hot Restart to function.
The app is loaded on my iPhone but when i start it it shows only the default xamarin launch screen.
But the app is not loading and no breakpoints in the Main.cs or AppDelegate.cs of the iOS project triggered.

0 Votes 0 ·

But build with appcenter.ms and distributed via testflight i got the blue background of the scrollview.

0 Votes 0 ·

I run your project it works fine , suggestion : update xamarin.forms to the latest , change the Linker to Don't link , try again .

Ps : pls delete your repo link , it contains your private app-center keys .

0 Votes 0 ·

Unfortunately nothing changed.

I got a Debug Stacktrace with Xamarin Hot Restart.
With "Dont Link" or "Link All" same issue.
I got the newest Xamarin.Forms Nuget-Package.

Here is the Stacktrace I think there is a problem with the mono runtime.

43616-stacktrace.txt


0 Votes 0 ·
stacktrace.txt (6.8 KiB)

There is no useful information in the log , consider raising issue here for better support : https://github.com/xamarin/Xamarin.Forms/issues .

0 Votes 0 ·
Show more comments