Looking at your code snippets I can see that you're adding the new item in a business collection of items. However, in order to get the SelectedContainer
of the RadTreeView
control, the RadTreeViewItem
container, that wraps the newly added and selected business item, should be generated.
But the RadTreeViewItem
containers of the business items in the RadTreeView
control are only generated after the business items is visualized - basically this means that after adding a new item, you need to make sure its ParentItem
is expanded to display it. In that case, the RadTreeView ItemPrepared
event will be fired for the newly added item and you can handle it to implement your custom logic.
Still, in databinding scenarios we recommend binding all properties of the RadTreeViewItem
containers, that you'll need to modify - IsExpanded
, etc. This way you won't have to wait for the containers to generate and you will only work with the data items in your view models. And as soon as the RadTreeViewItem
containers are generated, their property bindings will be applied accordingly.
All the best,
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>