Thank you for the example, it was really helpful.
I have an additional question:
If I use a datatemplate to display data, and I fill the ItemsSource of the treeview, I can trigger the Selected event of the treeview.
In the selected event, I can cast the tree.SelectedItem to a custom object.
Let's say that you don't fill the ItemsSource of the treeview, but instead create the RadTreeViewItems programatically.
|<Style TargetType="telerik:RadTreeViewItem" x:Key="TreeViewItemStyle"> ...
and placing something inside this style, the programatically created RadTreeViewItems are displayed.
Problem is inside the Selected event of the treeview, I get an error while trying to cast the SelectedItem to my custom object. Can this be done ?