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

Binding group headers

3 Answers 219 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ömer
Top achievements
Rank 1
Ömer asked on 17 Jul 2015, 11:54 AM

I have the following RadListView:

 

<telerik:RadListView x:Name="PhaseListView" ItemsSource="{Binding Items}">
         <telerik:RadListView.GroupHeaderTemplate>
           <DataTemplate>
             <StackLayout>
                 <Label Text="{Binding}" TextColor="White" HorizontalOptions="Center"></Label>
             </StackLayout>
           </DataTemplate>
         </telerik:RadListView.GroupHeaderTemplate>
         <telerik:RadListView.ItemTemplate>
           <DataTemplate>
             <template:ListViewTemplateCell >
               <template:ListViewTemplateCell.View>
                 <StackLayout>
                   <StackLayout Orientation="Horizontal">
                     <Label Text="{Binding ID}"></Label>
                   </StackLayout>
                   <Slider Value="{Binding Complete}" IsEnabled="False" HorizontalOptions="FillAndExpand"></Slider>
                 </StackLayout>
               </template:ListViewTemplateCell.View>
             </template:ListViewTemplateCell>
           </DataTemplate>
         </telerik:RadListView.ItemTemplate>
         <telerik:RadListView.LayoutDefinition>
           <template:ListViewLinearLayout Orientation="Vertical"/>
         </telerik:RadListView.LayoutDefinition>
       </telerik:RadListView>

The grouping is done in the code behind via:

public partial class PhaseXaml : ContentPage
    {
        public RadListView PhaseList { get; private set; }
 
        public PhaseXaml()
        {
            InitializeComponent();
            PhaseList = PhaseListView; // So it can be accessed from viewmodel
 
            var lookup = new DelegateGroupDescriptor{KeyExtractor = new PhaseGrouping().GetKey};
            PhaseListView.GroupDescriptors.Add(lookup);
 
            BindingContext = new PhaseViewModel(new PhaseRepository(), this);
        }
 
        private class PhaseGrouping : IKeyLookup
        {
            public object GetKey(object item)
            {
                var phase = (Phase) item;
                return phase.ProjectName;
            }
        }

The ProjectName property is a string, now it does group the items correctly but the header text remains empty. When I break in the GetKey method I can see that at that point the ProjectName property does have a value. I have tried other string Properties on the phase object and it appears that while it groups correctly the header stays empty. If I bind it to say an int (Project id) that will be displayed in the header.
I have attempted to group with a PropertyGroupDescriptor as well but that has the same results. I'm testing on an Android device at the moment.

 So my question is is there a way to get string properties to display in the groupheader, and if not whether it's possible to bind the text of the header to another property than is used to group the item (that we can assume is same for all items in the group)

3 Answers, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 22 Jul 2015, 11:16 AM
Hello Ă–mer,

Thank you for contacting us.

We must admit that there is an issue with the binding context of the group headers - it becomes null due to a problem with the conversion from Java.Lang.Object. We can not suggest a workaround at this moment. We will fix this issue for the next release. The official release is planned for the end of September, but it is very probable to have an internal build earlier.

I have updated your Telerik points as a token of gratitude for bringing this issue to our attention.

Please, let us know if you have any other questions.

Regards,
Rosy Topchiyska
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
0
Elad
Top achievements
Rank 1
answered on 07 Apr 2016, 10:55 AM

Hi,

is this issue solved? 

if not, is there any work around to set the template group header custom cell?

Thanks

0
Elad
Top achievements
Rank 1
answered on 07 Apr 2016, 12:46 PM

I can confirm this is solved in the latest release,

template should build as any layout view and not as ListViewGroupHeaderCell

 

Tags
ListView
Asked by
Ömer
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Elad
Top achievements
Rank 1
Share this question
or