We have discovered an issue in the TreeView for instances where IsVirtualizing is set to true and LoadOnDemand is enabled where the tree view ignores the OptionType setting for newly created items.
When the page loads, we loop through a collection of items and add them to the tree like so:
RadTreeViewItem itineraryTreeViewItem =
new
RadTreeViewItem
{
DataContext = foo,
Header = foo.name,
OptionType = OptionListType.CheckList,
IsLoadOnDemandEnabled =
true
};
itineraryTreeViewItem.LoadOnDemand += Treeview_LoadOnDemand;
control.Items.Add(itineraryTreeViewItem);
The pertinent code for the Treeview_LoadOnDemand method is below. I simplified it some as our actual code checks the datacontext of the source item and enables LoadOnDemand for certain types.
private
void
Treeview_LoadOnDemand(
object
sender, Telerik.Windows.RadRoutedEventArgs e)
{
var radTreeViewItem = (RadTreeViewItem)e.OriginalSource;
radTreeViewItem.IsExpanded =
true
;
var childItems = GetChildItems(radTreeViewItem.DataContext);
foreach
(var child
in
childItems)
{
var routeTreeViewItem =
new
RadTreeViewItem
{
DataContext = child,
Header = child.name,
OptionType = OptionListType.None
};
radTreeViewItem.Items.Add(tierTreeViewItem);
}
radTreeViewItem.IsLoadingOnDemand =
false
;
radTreeViewItem.LoadOnDemand -= Treeview_LoadOnDemand;
}
The resulting tree view displays a checkbox for every item in the tree, even though the child items have an OptionType of None. If I set IsVirtualizing to false, the items are created correctly. I would like to use the virtualizing feature though as we can have over 1000 items in our top layer and some of our clients are running very old machines.