I'm essentially trying to recreate the xaml below from your example here. I've been successful in creating a Tree View and a TreeViewDescriptor using only C# (no xaml) but I haven't been able to figure out how to create a more complex Tree View using an Item Template. The ItemTemplate property for a TreeViewDescriptor has a type of DataTemplate and that class only seems to have the properties Values and Bindings. These properties wouldn't be enough for me to define my grid for displaying my data. Am I able to define an ItemTemplate programmatically?
1.
<
telerikDataControls:RadTreeView
x:Name
=
"treeView"
ItemsSource
=
"{Binding Source}"
>
<
telerikDataControls:TreeViewDescriptor
DisplayMemberPath
=
"Name"
ItemsSourcePath
=
"Cities"
TargetType
=
"{x:Type local:Country}"
>
<
telerikDataControls:TreeViewDescriptor.ItemTemplate
>
<
DataTemplate
>
<
Grid
Margin
=
"{Binding Path=Level, Converter={StaticResource levelToMarginConverter}}"
HeightRequest
=
"40"
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"Auto"
/>
<
ColumnDefinition
Width
=
"Auto"
/>
<
ColumnDefinition
Width
=
"*"
/>
</
Grid.ColumnDefinitions
>
<
telerikTreeView:ExpandCollapseIndicator
FontSize
=
"Medium"
WidthRequest
=
"10"
Margin
=
"15,0"
VerticalTextAlignment
=
"Center"
IsLoading
=
"{Binding Path=IsLoading}"
IsLoadOnDemandEnabled
=
"{Binding Path=IsLoadOnDemandEnabled}"
IsExpanded
=
"{Binding Path=IsExpanded}"
IsLeaf
=
"{Binding Path=IsLeaf}"
/>
<
Image
Grid.Column
=
"1"
VerticalOptions
=
"Center"
Source
=
"{Binding Item.Icon, Converter={StaticResource ImageSourceConverter}}"
/>
<
telerikTreeView:ItemText
Grid.Column
=
"2"
Margin
=
"8,0,0,0"
VerticalOptions
=
"Center"
Text
=
"{Binding Item.Name}"
/>
</
Grid
>
</
DataTemplate
>
</
telerikDataControls:TreeViewDescriptor.ItemTemplate
>
</
telerikDataControls:TreeViewDescriptor
>
<
telerikDataControls:TreeViewDescriptor
DisplayMemberPath
=
"Name"
TargetType
=
"{x:Type local:City}"
/>
</
telerikDataControls:RadTreeView
>