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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

RefreshView not triggering group header converter

Thread ID:

Created:

Updated:

Platform:

Replies:

143005 Feb 28,2019 10:39 AM UTC Mar 15,2019 10:44 AM UTC Xamarin.Forms 7
loading
Tags: SfListView
Giorgi Dalakishvili
Asked On February 28, 2019 01:14 PM UTC

I have a listview (SfListView version: 16.4.0.53) bound to a list of objects. The listview is grouped by one of the properties and I am using a converter to show summary information in group header. When the user clicks one of the buttons I update the datasource and call ListView.RefreshView(). The converter for the item binding is getting called but the converter of the group header isn't so the header shows out of date information.

Can you fix the issue?

Gnana Priya Namasivayam [Syncfusion]
Replied On March 2, 2019 12:17 AM UTC

Hi Giorgi, 
 
 
Thanks for using Syncfusion support. 
 
We have checked the reported query from our side. We have prepared the sample as mentioned grouped based on one of property and we simply suggest to that you can display summary (if it is count of items means) in group header by binding directly `Count` property because Group Header will have its GroupResult as its BindingContext from the GroupResult you can display Key, Count, IsExpand…In our sample, we have updated data at runtime which updates in Group Header summary accordingly. We have attached the sample for your reference, please find the sample from below. 
 
 
Can you please check with the above sample whether it meets your requirement. 
 
If you are trying to display other than summary of items(other than count) in group header, can you please share the code snippet you have used in converter and group header template to display the details in group header view. So that we can under your requirement and provide the better solution at our end. 
 
Regards, 
Gnana Priya N 


Giorgi Dalakishvili
Replied On March 11, 2019 02:13 PM UTC

This is how my group header template looks like:

        <xForms:SfListView.GroupHeaderTemplate>
          <DataTemplate>
            <ViewCell>
              <ViewCell.View>
                <StackLayout Orientation="Horizontal">
                  <Label Text="{Binding Key}" TextColor="White" FontSize="{x:OnIdiom Phone=Medium, Tablet=Large, Default=Medium}" FontAttributes="Bold" VerticalOptions="Center" HorizontalOptions="Start" />
                  <Label Text="{Binding Items, Converter={StaticResource HeaderDurationConverter}}" MinimumWidthRequest="60" TextColor="White" FontSize="{x:OnIdiom Phone=Medium, Tablet=Large, Default=Medium}"
                                                                                                    FontAttributes="Bold" VerticalOptions="Center" HorizontalOptions="End" />
                  <Image Source="{Binding Items, Converter={StaticResource HeaderIconConverter}}" VerticalOptions="Center">
                  </Image>
                </StackLayout>
              </ViewCell.View>
            </ViewCell>
          </DataTemplate>
        </xForms:SfListView.GroupHeaderTemplate>

When I call ListView.RefreshView() the image is not changed.

Deivaselvan Y [Syncfusion]
Replied On March 12, 2019 10:04 AM UTC

Hi Giorgi, 
 
We have checked the shared code snippet from our side. If your requirement is to change the icon in group header template then you can bind `IsExpand` bool property which return image from converter based on Expand, Collapse state of the group like below. We have attached the sample for your reference, please refer the sample from below. 
 
 
Xaml 
 
<syncfusion:SfListView AllowGroupExpandCollapse="True" 
                      ItemsSource="{Binding contactsinfo}"> 
                <syncfusion:SfListView.GroupHeaderTemplate> 
                    <DataTemplate> 
                        <Grid > 
                            <Grid.ColumnDefinitions> 
                                <Image Source="{Binding IsExpand, Converter={StaticResource BoolToImageConverter}}"/> 
                            </StackLayout> 
                        </Grid> 
                    </DataTemplate> 
                </syncfusion:SfListView.GroupHeaderTemplate> 
</syncfusion:SfListView> 
 
Converter 
 
  public class BoolToImageConverter : IValueConverter 
    { 
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
        { 
            if ((bool)value) 
            { 
                return ImageSource.FromResource("SfListViewSample.Images.GroupExpand.png"); 
            } 
            else 
            { 
                return ImageSource.FromResource("SfListViewSample.Images.GroupCollapse.png"); 
            } 
        } 
 
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
        { 
            throw new NotImplementedException(); 
        } 
    } 
 
To know more about group header customization, you can also refer our documentation link below. 
 
 
Please let us know if you have any further queries. 
 
Regards, 
Deivaselvan 


Giorgi Dalakishvili
Replied On March 12, 2019 11:05 AM UTC

I am not trying to show expand/collapse image. I just need to set image based on the Items in the group that's why I am passing Items collection to the converter.

Deivaselvan Y [Syncfusion]
Replied On March 14, 2019 12:00 PM UTC

Hi Giorgi,  
  
You can set items in the converter to handle what you need to do in the group like below. We have attached the sample for your reference, please refer the sample from below.  
  
 
Xaml  
  
<syncfusion:SfListView AllowGroupExpandCollapse="True" ItemsSource="{Binding contactsinfo}">  
   <syncfusion:SfListView.GroupHeaderTemplate> 
                    <DataTemplate> 
                        <Grid BackgroundColor="#E4E4E4"> 
                            <Grid.ColumnDefinitions> 
                                <ColumnDefinition Width="*"/> 
                                <ColumnDefinition Width="*"/> 
                            </Grid.ColumnDefinitions> 
                            <StackLayout Orientation="Horizontal" HorizontalOptions="Start" VerticalOptions="Center" Padding="10,0,0,0"> 
                                <Label Text="{Binding Key}" TextColor="Black" FontSize="Medium"/> 
                            </StackLayout> 
                            <StackLayout Orientation="Horizontal" Grid.Column="1" Padding="0,0,20,0" 
                                              HorizontalOptions="EndAndExpand" VerticalOptions="Center"> 
                                <Label Text="{Binding Count}" TextColor="Black" FontSize="Medium"/> 
                                <Label Text="Item(s)" TextColor="Black" FontSize="Medium"/> 
                                <Image Source="{Binding Items, Converter={StaticResource BoolToImageConverter}}" HeightRequest="50" WidthRequest="100"/> 
                            </StackLayout> 
                        </Grid> 
                    </DataTemplate> 
                </syncfusion:SfListView.GroupHeaderTemplate>  
</syncfusion:SfListView>  
  
Converter  
  
public class BoolToImageConverter : IValueConverter 
    { 
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
        { 
            var image = ImageSource.FromResource("SfListViewSample.Images.GroupExpand.png"); 
            var items = value as IEnumerable; 
            if (items != null) 
            { 
                var groupitems = items.ToList<object>().ToList<object>(); 
 
                if (groupitems != null) 
                { 
                    for (int i = 0; i < groupitems.Count; i++) 
                    { 
                        var contact = groupitems[i] as Contacts; 
                        if (contact.ContactName == "Kenny") 
                            image = ImageSource.FromResource("SfListViewSample.Images.new.jpg"); 
                    } 
                } 
            } 
 
            return image; 
        } 
 
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
        { 
            throw new NotImplementedException(); 
        } 
    } 
  
Please let us know if you have any further queries.  
  
Regards,  
Deivaselvan 


Giorgi Dalakishvili
Replied On March 14, 2019 10:07 PM UTC

That's what I am doing but when I update any item the group header image doesn't change even if I call RefreshView on the listview.

Deivaselvan Y [Syncfusion]
Replied On March 15, 2019 10:44 AM UTC

Hi Giorgi,

 
We have ensured to update the item name and add the new item in run time, But unfortunately the reported issue is not reproduced in our end. So, you can revert us with the modified sample, and provide the below details. 
 
1.      Which platforms do you faced this issue? 
2.      Which version of Xamarin forms do you have used in your sample. 
3.      Reproduce the issue in below sample. It is also used your xaml template. 
 
 
Please let us know if you have any further queries. 
 
Regards, 
Deivaselvan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;