Hello
The SelectedItem property of the treeview does not always contain what I would expect.
Examples:
How should I handle these use cases? Binding to another property?
Best regards,
Franziska
The SelectedItem property of the treeview does not always contain what I would expect.
Examples:
- Cancel Selection
The ItemsSource property is bound to a collection containing A and B objects. I want that only the A object are selectable. The B objects are just for information. I use the following code:
void radTreeView_PreviewSelected(object sender, Telerik.Windows.RadRoutedEventArgs e) { // get a reference to the item that will be selected RadTreeViewItem itemToSelect = e.OriginalSource as RadTreeViewItem; // check item that will be selected if (itemToSelect != null && itemToSelect.Item is B) { e.Handled = true; } } - Remove the selected item from the bound collection
If I remove the currently selected item from the bound collection, then the node has disappeard as I expected, but the SelectedItem property still contains the removed object. I would expect, that the SelectedItem property always contains objects that are also in the ItemsCollection or null otherwise.
How should I handle these use cases? Binding to another property?
Best regards,
Franziska