Search code examples
c#xamaringroupingsyncfusion

How to turn off a Group header in SfListView?


I have a problem.I want to turn off a Group header in SfListView.I read on the forums to turn off IsStickyGroupHeader,I did it but IsStickyGroupHeader="False" does not work.Maybe I understand something wrong.Please help me.Thank you

 <syncfusion:SfListView
                x:Name="listView"
                Grid.Row="0"
                ItemSize="40"
                IsStickyGroupHeader="False"
                ItemsSource="{Binding contactsinfo}"
                SelectionMode="None">

                <syncfusion:SfListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <ViewCell.View>
                                <StackLayout>
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="100" />
                                            <ColumnDefinition Width="*" />

                                        </Grid.ColumnDefinitions>

                                        <StackLayout
                                            Grid.Column="1"
                                            HorizontalOptions="StartAndExpand"
                                            Orientation="Vertical"
                                            VerticalOptions="Center">
                                            <Label
                                                HorizontalOptions="Center"
                                                HorizontalTextAlignment="Center"
                                                LineBreakMode="WordWrap"
                                                Text="{Binding ContactName}"
                                                TextColor="#474747"
                                                VerticalOptions="Center"
                                                VerticalTextAlignment="Center" />

                                        </StackLayout>
                                    </Grid>

                                    <StackLayout BackgroundColor="LightGray" HeightRequest="1" />

                                </StackLayout>
                            </ViewCell.View>
                        </ViewCell>
                    </DataTemplate>
                </syncfusion:SfListView.ItemTemplate>
            </syncfusion:SfListView>

enter image description here


Solution

  • You can hide the GroupHeader by using the GroupHeaderSize as 0. Please refer to the following code snippets,

    <ListView:SfListView 
                    x:Name="listView"
                    Grid.Row="0"
                    ItemSize="40"
                    GroupHeaderSize="0"
                    ItemsSource="{Binding ContactsInfo}"
                    SelectionMode="None">
    

    You can also refer to our user guidance document regarding the same, UG link: https://help.syncfusion.com/xamarin/listview/grouping#height-customization

    Also, if you are using SfListView.AutoFitMode as Height or DynamicHeight, then the items size will be calculated based on the template elements. Hence, you can customize the GroupHeaderTemplate with Height 0.

    <ListView:SfListView 
            x:Name="listView"
            Grid.Row="0"
            AutoFitMode="DynamicHeight"
            ItemsSource="{Binding ContactsInfo}"
            SelectionMode="None">
        <ListView:SfListView.GroupHeaderTemplate>
            <DataTemplate>
                <ViewCell Height="0"/>
            </DataTemplate>
        </ListView:SfListView.GroupHeaderTemplate>
    

    Refer the following documentation regarding the same, UG link: https://help.syncfusion.com/xamarin/listview/grouping#group-header-customization