Hi scott,
As I managed to understand, your wish is to disable selecting both Extensions and Greetings.
First of all, a possible problem is that when you are "foreach-ing" SelectedItems collections and set IsSelected in the body of the foreach statement, the collection gets changed, indices are rearranged and etc. which may lead to various issues. Secondly, its bad practice to set Selected properties in selected event since this again fires selected event and you have to write additonal code to prevent cycles, recursions ... the PreviewSelected and PreviewSelectionChanged events are a bit better idea but still not a good practice in this scenario. Additionally , you should be aware that in extended selection mode, the following is always true; tree.SelectedItem == tree.SelectedItems[0]. So you cannot rely that the SelectedItem in the Selected event handler is the last selected : SelectedItems[n - 1].
However, I modified your solution to use the ItemClick event of the RadTreeView. I check whether the currently clicked item`s type is different from the SelectedItems`type ( I guess you wish this collection to include elements of single type). If so, clear the SelectedItems and selected the clicked item.
Please let me know if this approach satisfies you.
privatevoid
RadTreeView_SelectionChanged(
object
sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
{
}
privatevoid
treeviewProvantage_ItemDoubleClick(
object
sender, Telerik.Windows.RadRoutedEventArgs e)
{
}
privatevoid
treeviewProvantage_PreviewSelected(
object
sender, Telerik.Windows.RadRoutedEventArgs e)
{
}
privatevoid
treeviewProvantage_Selected(
object
sender, Telerik.Windows.RadRoutedEventArgs e)
{
}
privatevoid
treeviewProvantage_ItemClick(
object
sender, Telerik.Windows.RadRoutedEventArgs e)
{
var item = (e.OriginalSource asRadTreeViewItem).Item;
ItemType selectedItemsType = (this.treeviewProvantage.SelectedItem asProvatageItem).MyType;
if(selectedItemsType != (item asProvatageItem).MyType)
{
this.treeviewProvantage.SelectedItems.Clear();
}
(item asProvatageItem).isSelected = true;
}
Best wishes,
Petar Mladenov
the Telerik team