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)