As far as I understand you refer to this article
and you are concerned about the following cast:
sender, Telerik.Windows.Controls.SelectionChangedEventArgs e )
// Get a reference to the treeview
Telerik.Windows.Controls.RadTreeView treeView = sender
// Get the currently selected items
ObservableCollection<Object> selectedItems = treeView.SelectedItems;
RadTreeViewItem item = selectedItems[ 0 ]
// Get the previous item and the previous sibling item
RadTreeViewItem previousItem = item.PreviousItem;
RadTreeViewItem previousSiblingItem = item.PreviousSiblingItem;
// Get the next item and the next sibling item
RadTreeViewItem nextItem = item.NextItem;
RadTreeViewItem nextSiblingItem = item.NextSiblingItem;
// Get the parent item and the root item
RadTreeViewItem parentItem = item.ParentItem;
RadTreeViewItem rootItem = item.RootItem;
Please note that the RadTreeView
control in the referenced article is XAML defined, hence the SelectedItems
collection consists of RadTreeViewItems
, only. Hence the cast will always be successful.
However, if you use data bindings you actually use the RadTreeView
control in different scenario and the SelectedItems
collection will hold your business items.
Regarding your last sentence - I am not sure that I understand your point. Could you please clarify what you have in mind when you say: "In both RadTreeView and RadTreeViewItem, Item and its Container should be clearly different.
Pavel R. Pavlov
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>