locked
How to use a Frame as the root element of a ListView in Xamarin.Forms? RRS feed

  • Question

  • User313489 posted

    I am trying to achieve a list of Card-like records for the timeline on an application built in Xamarin.Forms, this is the layout that more or less I need to replicate:

    I think I am close, I have two records on my code behind that I assign as the ItemSource to a listView on the XAML side, and this is my result so far:

    But as you can see, the elements are not showing at all inside their frame, if I replace the form controls with TextCells or ImageCells, the data shows fine. This is the XAML code I have so far:

    <?xml version="1.0" encoding="UTF-8"?>
    <ContentPage Title="AudioBitts" 
        xmlns="http://xamarin.com/schemas/2014/forms" 
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:local="clr-namespace:AudioBitts"
        x:Class="AudioBitts.TimelinePage">
    
        <ListView x:Name="listView">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell Height="300">
                        <Frame HasShadow="true" Margin="5">
                            <StackLayout>
                                <StackLayout Orientation="Horizontal">
                                    <Image Source="{Binding UserAvatar}" />
                                    <Label Text="{Binding UserName}" />
                                </StackLayout>
                                <Image Source="{Binding BittImage}" />
                            </StackLayout>
                        </Frame>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    
    </ContentPage>
    

    Am I missing something on the structure I am giving to my XAML code? Thanks!

    Monday, April 10, 2017 4:33 AM

Answers

  • User207279 posted

    @"EduardoIbarra.0913" Instead of assigning height to ViewCell, try to set RowHeight property of ListView which should show the content of the Frame.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, April 10, 2017 5:09 AM

All replies

  • User207279 posted

    @"EduardoIbarra.0913" Instead of assigning height to ViewCell, try to set RowHeight property of ListView which should show the content of the Frame.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, April 10, 2017 5:09 AM
  • User370108 posted

    @EduardoIbarra.0913 you have to make the property HasUnEvenRows in ListView true :)

    Saturday, June 23, 2018 7:31 AM