[FIXED] ListView GroupHeader item not set fixed height how to change Groupheader item values in xamarin forms

Issue

The code below works fine in Android, however in iOS it’s not working as expected. The issue is that the height seems to be any alternative for this solution. Thanks in Advance.

<ListView.GroupHeaderTemplate>
                    <DataTemplate>
                        <ViewCell>
                                <Grid BackgroundColor="White" ColumnSpacing="5">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                       
                                    </Grid.ColumnDefinitions>

                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>

                                    <Label Text="{Binding Key.OperationId}" IsVisible="false"/>
                                    <Image Source="{Binding Key.ImageUrl}" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" WidthRequest="50"  HeightRequest="50" VerticalOptions="StartAndExpand" HorizontalOptions="StartAndExpand" />
                                    <Label Text="{Binding Key.Description}" Grid.Row="0" Grid.Column="1" FontAttributes="Bold" TextColor="Black" 
                                            VerticalOptions="StartAndExpand" HorizontalOptions="StartAndExpand" FontSize="15" />
                                    <Label Text="{Binding Key.Code}" Grid.Row="1" Grid.Column="1" TextColor="Black" VerticalOptions="StartAndExpand" HorizontalOptions="StartAndExpand" FontSize="15" />
                                </Grid>
                        </ViewCell>
                    </DataTemplate>
                </ListView.GroupHeaderTemplate>

Solution

This potential issue is being tracked on this thread: https://github.com/xamarin/Xamarin.Forms/issues/3769

There is a gist in the comments suggesting creating a custom renderer to fix the ListView GroupHeader size in iOS: https://gist.github.com/nbevans/a713dc9c77a8f530b6f4f3cd4fad83c2

Reference link.

Answered By – Alexandar May – MSFT

Answer Checked By – Dawn Plyler (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published