We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Exception When End of data reached Custom grouping ?

Hi I have a sfListView,

I am binding to a list of "AgriNotes" each item has a date (DateTime), data(string), and type (string)

When i try and custom group based on the type, i am getting an exception.

Type can be a string from 1 to 11 ("1","2", ... "11")

CS Code Below 

listView.DataSource.GroupDescriptors.Add(new GroupDescriptor()

            {

                PropertyName = "Type",

                KeySelector = (object obj1) =>

                {

                    var item = obj1 as AgriNote;

                    switch(item.Type)

                    {

                        case "1":

                            return "Testing";

                        case "2":

                            return "Something else";

                        default:

                            return "Other";

                    }

                },

            });

Xaml


<listView:SfListView x:Name="listView" AutoFitMode="Height" ItemsSource="{Binding Notes}" BackgroundColor="WhiteSmoke" AllowGroupExpandCollapse="True" >

                                            <listView:SfListView.ItemTemplate>

                                                    <DataTemplate>

                                                        <ViewCell>

                                                            <StackLayout Orientation="Vertical" Margin="10,10" HorizontalOptions="CenterAndExpand">

                                                                <Label Text="{Binding Created}" FontAttributes="Bold" TextColor="Black" FontSize="14"/>

                                                                <Label Text="{Binding Note}" TextColor="Black" FontSize="12" LineBreakMode="WordWrap"/>

                                                                <Label Text="{Binding Type}" TextColor="Black" FontSize="12" LineBreakMode="WordWrap"/>

                                                            </StackLayout>

                                                        </ViewCell>

                                                    </DataTemplate>

                                                </listView:SfListView.ItemTemplate>

                                            </listView:SfListView>

                                        </Grid>


Stepping through the CS code appears to work fine as in different values are returned fine after the last item i get a Null exception. I am calling this code in the constructor of the page but after ive set the binding context Is that too soon ?

thanks peter




1 Reply

SY Suthi Yuvaraj Syncfusion Team October 17, 2022 06:13 AM

Hi Peter,


We have checked the reported query “Exception When End of data reached Custom grouping” from our end. We are unable to replicate the reported crash , we have tried by binding the binding context and added the groupdescriptor  in the constructor is working fine. We have attached the workable sample for your reference. Please let us know if you are still facing the issue.


If yes, Please provide the below details or modify the sample to replicate the issue, which will be more helpful for us know to find the solution as soon as possible.

  1. Code snippet related SfListView and data population
  2. Code snippet related to grouping and customization
  3. Platform related details.
  4. Replication Video to reproduce the issue.
  5. Syncfusion and Xamarin.Forms versions.


Please let us know if you need further assistance.


Regards,

Suthi Yuvaraj.


Attachment: GettingStarted_12d48c70.zip

Loader.
Live Chat Icon For mobile
Up arrow icon