GroupHeaderTemplate DataTemplate DataType

Hello,

What is the DataType I should use in the next piece of source code in SfListView:


Image_9418_1736316364502

Best regards


3 Replies

SJ Sowntharya Jayamoorthy Syncfusion Team January 9, 2025 05:46 AM UTC

Hi Customer,

The DataType for the GroupHeaderTemplate in the SfListView is GroupResult. This ensures that the binding context for the group headers is correctly identified, and you can access properties such as Key and Items.
Please refer the following code snippet

Code snippet:

<ContentPage xmlns=http://schemas.microsoft.com/dotnet/2021/maui

                         xmlns:dataSource="clr-namespace:Syncfusion.Maui.DataSource;assembly=Syncfusion.Maui.DataSource"

             x:DataType="ViewModel:MainPageViewModel">
 

 <syncfusion:SfListView.GroupHeaderTemplate>

     <DataTemplate x:DataType=" dataSource:GroupResult">

       <!-- Add your group header content here -->

    </DataTemplate>

</syncfusion:SfListView.GroupHeaderTemplate>

 

 





RC Rogerio C Mauri January 18, 2025 09:13 PM UTC

I get error stating that GroupResult does not exist in the context



SJ Sowntharya Jayamoorthy Syncfusion Team January 20, 2025 06:49 AM UTC

Hi Rogerio,


Sorry for the inconvenience caused.
The (GroupResult) DataType used in the GroupHeaderTemplate belongs to the DataSource.Extensions namespace. Please refer the following code snippet.

<ContentPage xmlns=http://schemas.microsoft.com/dotnet/2021/maui

xmlns:dataExtension="clr-namespace:Syncfusion.Maui.DataSource.Extensions;assembly=Syncfusion.Maui.DataSource"
             x:DataType="ViewModel:MainPageViewModel">

 <syncfusion:SfListView.GroupHeaderTemplate>

     <DataTemplate x:DataType="dataExtension:GroupResult">

       <!-- Add your group header content here -->

    </DataTemplate>

</syncfusion:SfListView.GroupHeaderTemplate>

 


Regards,

Sowntharya Jayamoorthy


Loader.
Up arrow icon