Forum Xamarin Xamarin.Forms

ListView shows empty rows.

thaufeethaufee Member ✭✭
edited June 2019 in Xamarin.Forms

I do have list view in my Xamarin Forms Application.

XAML Code:

<ListView x:Name="ItemsListView" VerticalOptions="FillAndExpand"
    HasUnevenRows="true" IsPullToRefreshEnabled="true" SeparatorVisibility="None"
    Refreshing="ItemsListView_Refreshing" ItemSelected="ItemsListView_ItemSelected">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <Frame Style="{DynamicResource CorneredFrame}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="8" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <BoxView Grid.Row="0" Grid.Column="0" Grid.RowSpan="3" BackgroundColor="{Binding EventColorCode}" />
                        <Label Grid.Row="0" Grid.Column="1" Text="{Binding NotificationSubject}" Margin="5,5,5,0" FontAttributes="Bold" FontSize="{DynamicResource Medium}" />
                        <Label Grid.Row="1" Grid.Column="1" Text="{Binding NotificationText}" Margin="5,0,5,0" FontSize="{DynamicResource Small}" />
                        <Label Grid.Row="2" Grid.Column="1" Text="{Binding CreatedAt, StringFormat='{}{0:dd MMM, yyyy hh:mm tt}'}" Margin="5,0,5,5" FontSize="{DynamicResource VerySmall}" />
                    </Grid>
                </Frame>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Output:

I do not know why it is showing empty rows.

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited June 2019

    I reproduced you code and it works well. Check the binding of BoxView's BackgroundColor and Label's Text. You can set the specified value to check it.

  • thaufeethaufee Member ✭✭

    @yelinzh said:
    I reproduced you code and it works well. Check the binding of BoxView's BackgroundColor and Label's Text. You can set the specified value to check it.

    I have 10 items in the list view. First items are okay. The rest are showing blank rows. I have no idea, why?

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited June 2019

    @thaufee
    Could you post the code about data binding and Model.cs?

  • M0BilalM0Bilal USMember ✭✭

    Same issue I am facing. The data is there in the ItemsSource but it's showing for first few rows only. Rest of them are empty. Did you find any solution for this @thaufee?

  • Rameshbodh_Rameshbodh_ Member ✭✭

    @M0Bilal @thaufee

    I have been also facing exactly same issue
    updating Xamarin.Forms to latest worked for me ;)

    thanks

Sign In or Register to comment.