ListView not displaying in Xamarin.Forms/macOS project

zintjrzintjr Member ✭✭
edited August 2018 in Xamarin.Forms

I have a Xamarin.Forms macOS project with a ListView that has IsGroupingEnabled=true and can't get it to display when I run the app.

The ListView displays with data in the Preview window and on the iOS simulator but when running the mac project it just shows a blank white screen. ListViews do work on macOS right? Am I missing something else? Thanks!

<?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:IntegratorSimpleXF"
    x:Class="IntegratorSimpleXF.MainPage">

    <ListView 
        x:Name="PresenceListView" 
        BackgroundColor="White" 
        CachingStrategy="RecycleElement"  
        IsGroupingEnabled="true" 
        GroupDisplayBinding="{Binding Key}">

        <ListView.GroupHeaderTemplate>
            <DataTemplate>
                <ViewCell>
                    <ContentView Padding="5,0,0,0">
                        <Label Text="{Binding Key}" VerticalOptions="Center"/>
                    </ContentView>
              </ViewCell>
            </DataTemplate>
        </ListView.GroupHeaderTemplate>

        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell Height="40">

                    <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand" BackgroundColor="White">                  

                        <StackLayout Orientation="Vertical" WidthRequest="160" Margin="10,0,0,0" Spacing="0" HorizontalOptions="StartAndExpand">
                            <Label TextColor="Black" LineBreakMode="TailTruncation" HorizontalOptions="StartAndExpand" Text="{Binding FullName}" Margin="15,3,0,0" FontSize="Small" />
                            <Label TextColor="Blue" Text="{Binding PhoneExtension}" Margin="15,0,0,2" FontSize="Small" />
                        </StackLayout>

                        <StackLayout Orientation="Horizontal" HeightRequest="20" WidthRequest="10" VerticalOptions="Start" HorizontalOptions="CenterAndExpand" Margin="10,3,0,0" >
                            <Image HorizontalOptions="Center" HeightRequest="10" WidthRequest="10" IsVisible="{Binding IsAvailable}" Source="green_checkmark" Margin="0,0,0,2" />
                            <Frame IsVisible="{Binding IsNotAvailable}" BackgroundColor="Transparent" HeightRequest="10" WidthRequest="10"/>
                        </StackLayout>

                        <Label Text="{Binding PersonStatus}" HeightRequest="20" WidthRequest="100" HorizontalTextAlignment="Start" TextColor="Black" FontSize="Small" Margin="0,3,3,0" />                       
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

</ContentPage>
Tagged:

Answers

  • @zintjr have you tried removing IsGroupingEnabled=true, if data showing in list? Just asking to make sure its not data related issue in real device.

Sign In or Register to comment.