Using the following;
<telerikDataControls:RadTreeView x:Name="treeView" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" ItemsSource="{Binding RunList}"> <telerikDataControls:TreeViewDescriptor DisplayMemberPath="RunStart" TargetType="{x:Type viewModels:DriverRunVm}" ItemsSourcePath="Jobs"> </telerikDataControls:TreeViewDescriptor> <telerikDataControls:TreeViewDescriptor DisplayMemberPath="JobLine1" TargetType="{x:Type viewModels:JobVm}"/></telerikDataControls:RadTreeView>
The treeview displays the "RunStart" value in the header followed by the list of Jobs. If I change this to;
<telerikDataControls:RadTreeView x:Name="treeView" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" ItemsSource="{Binding RunList}"> <telerikDataControls:TreeViewDescriptor DisplayMemberPath="RunStart" TargetType="{x:Type viewModels:DriverRunVm}" ItemsSourcePath="Jobs" ItemTemplate="{StaticResource RunHeaderTemplate}"> </telerikDataControls:TreeViewDescriptor> <telerikDataControls:TreeViewDescriptor DisplayMemberPath="JobLine1" TargetType="{x:Type viewModels:JobVm}"/></telerikDataControls:RadTreeView>
And use this template;
<ContentPage.Resources> <ResourceDictionary> <DataTemplate x:Key="RunHeaderTemplate"> <Grid BackgroundColor="#ffb999" RowSpacing="0" Padding="5,2,5,0" Margin="0"> <Grid.RowDefinitions> <RowDefinition Height="auto" /> <RowDefinition Height="auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Label Grid.Row="0" Grid.Column="0" Text="Start:" TextColor="{StaticResource DarkSlateGrey}" FontSize="17" Margin="0" HorizontalOptions="End" VerticalOptions="CenterAndExpand"/> <Label Grid.Row="0" Grid.Column="1" Text="{Binding RunStart}" TextColor="{StaticResource DarkSlateGrey}" FontSize="17" Margin="0" HorizontalOptions="Start" VerticalOptions="CenterAndExpand"/> </Grid> </DataTemplate> </ResourceDictionary></ContentPage.Resources>
The label "Start:" is displayed however the error "[0:] Binding: 'RunStart' property not found on 'Telerik.XamarinForms.DataControls.TreeView.TreeViewDataItem', target property: 'Xamarin.Forms.Label.Text'" is reported.
I have tried using "treeView:ItemText" instead of a label but I get the same error. So I don't understand how the "DisplayMemberPath" displays the start value correctly but the same property in the template doesn't work.