Thank you all for the input & Joey for the sample project!
The main reason for the strange behavior is that we have not anticipated that the LoadOnDemand will be used twice for one and the same item.
But let me explain a little how the LoadOnDemand works:
After the user expands an item that has IsLoadOnDemandEnabled = true, the LoadOnDemand event is raised and IsLoadingOnDemand property is set to true (it controls the spinning arrows animation).
Then whenever the ItemsSource of the TreeViewItem is updated, its IsExpanded property is set to true, the IsLoadingOnDemand is set to false and the items appear.
- neweing up the items collection does not seem to work because the Children property is not observable, defining it like so will notify the TreeView accordingly:
_children = value;
newing up the collection will have the effect of clearing the items collection or removing all items.
When the TreeViewItems children are removed / reset, it sets is IsExpadned property to false.
Then, as I mentioned, we did not expect that LoadOnDemand will be used for the same item and you get the double-expand / click bug.
If you stop the LoadOnDemand when the items are retrieved, the TreeViewItem will work as expected:
Stopping LoadOnDemand when items are retrieved is a good idea if there are no children, since it will remove the arrow.
We can help by doing to things:
(1) Automatically set IsLoadOnDemandEnabled to false once items are updated. (like in the code above)
(2) Make sure loading on demand works the second+ time as well
Both have advantages & disadvantages - so which one would you prefer?
Do you need to fetch items twice?
@Joey - I updated your Telerik Points.
@All - Does setting IsLoadOnDemandEnabled to false after the children are retrieved help in your case?
All the best,
the Telerik team
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 Public Issue Tracking
system and vote to affect the priority of the items