This is a migrated thread and some comments may be shown as answers.

Listview GroupHeaderTemplate not showing property from Model

1 Answer 195 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Chintan
Top achievements
Rank 1
Chintan asked on 23 Aug 2017, 07:24 PM

 

Hi,

Below are model properties.

I am trying to group my list base on the CategoryName and trying to show CategoryName and HealthItemName in my custom header

Problem: I am able to see the CategoryName  in the header but trying but not able to show up HealthItemName  in my header.

I am using GroupHeaderTemplate to accomplish the above task. Any pointers?

 

model class elements {

    String CategoryName
        String CategoryHealthStatusText { get; set; }
        String HealthItemName { get; set; }

}

 

 

<telerikDataControls:RadListView AutomationId="RiskList" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" ItemsSource="{Binding Model.RiskItems}" SelectionMode="None">
                <telerikDataControls:RadListView.ItemStyle>
                    <telerikListView:ListViewItemStyle BackgroundColor="Transparent" BorderLocation="Bottom"/>
                </telerikDataControls:RadListView.ItemStyle>
                <telerikDataControls:RadListView.ItemTemplate>
                    <DataTemplate>
                        <telerikListView:ListViewTemplateCell>
                            <telerikListView:ListViewTemplateCell.View>
                                <StackLayout Padding="0,10" >
                                    <Label AutomationId="LabsResultsDate" Text="{Binding HealthItemName}"></Label>
                                </StackLayout>
                            </telerikListView:ListViewTemplateCell.View>
                        </telerikListView:ListViewTemplateCell>
                    </DataTemplate>
                </telerikDataControls:RadListView.ItemTemplate>
                <telerikDataControls:RadListView.GroupDescriptors>
                    <telerikListView:PropertyGroupDescriptor   PropertyName="CategoryName"/>
                </telerikDataControls:RadListView.GroupDescriptors>
               
                <telerikDataControls:RadListView.GroupHeaderTemplate >
                    <DataTemplate>
                        <StackLayout>
                            <svg:SvgCachedImage AutomationId="CategorySvg" WidthRequest="44" HeightRequest="44" Source= "resource://InteractiveHealth.Mobile.Member.Images.icons.cross_or6.svg"  />
                            <Label Text="{Binding }" HorizontalOptions="Center"/>
                            <Label Text="{Binding HealthItemName}" HorizontalOptions="Center"/>
                        </StackLayout>
                        <!--<Grid BackgroundColor="Red">
                            <Label Text="{Binding }" TextColor="#303030" FontSize="Medium" HorizontalOptions="Center"/>
                        </Grid>-->
                    </DataTemplate>
                </telerikDataControls:RadListView.GroupHeaderTemplate>
            </telerikDataControls:RadListView>

1 Answer, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 25 Aug 2017, 10:26 AM
Hello Chintan,

This behavior would be expected as when you are grouping by a specific property, only this property's value is the same for the whole group. The BindingContext of the Group is not an actual item from the source collection as the HealthItemName can be different for the different items from the group. Only the CategoryName is for sure the same for all these items.

Regards,
Stefan Nenchev
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListView
Asked by
Chintan
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Share this question
or