Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set height of row in ListView DataTemplate

Question

How can I increase the height of each row in my DataTemplate. I've set the height multiple times in different elements, however the row height doesn't change from the seemingly default height.

What am I missing?

Xaml

 <ListView x:Name="ListViewItems">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell Tapped="TapGestureRecognizer_Tapped" Height="400">
                            <Grid Padding="5" Margin="5" HeightRequest="400">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="400"/>
                                </Grid.RowDefinitions>
                                <Label Text="{Binding Title}" Grid.Row="0" Grid.Column="1" FontSize="15"/>
                                <Image Source="@drawable/cereals.png" Aspect="AspectFill" HeightRequest="400" Grid.Row="0" Grid.Column="0" />
                            </Grid>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

Screenshot

enter image description here

like image 858
Dan Cundy Avatar asked Dec 03 '25 09:12

Dan Cundy


1 Answers

If you want to allow a ListView row to set its own height, you need to set the ListView HasUnevenRows property to true.

like image 55
Steve Chadbourne Avatar answered Dec 05 '25 11:12

Steve Chadbourne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!