I have a RadTreeView with items and subitems:
All
1
1.1
1.2
1.3
2
2.1
2.2
2.3
Each subitem are associated to a RadTabControl/RadTabItem. When an item was checked in my treeview, I create dynamically a RadTabItem and when a user uncheck and item in my treeview, I remove it's associated RadTabItem from RadTabControl.
The problem is, when the user try to uncheck the item associated with the active RadTabItem in my RadTabControl, in my PreviewUnchecked event, I set the e.Handled property to true to prevent the remove of my RadTabItem in my Unchecked event.
Here is the piece of code:
private void radTreeViewDepartments_Unchecked(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
RadTreeViewItem item = e.OriginalSource as RadTreeViewItem;
//Remove a page if it's the lowest level item and if it's not the active tab.
if (item != null && !item.HasItems && item.Tag != null)
{
(item.Tag
as RadTabItem).Content = null;
RadTabControlDepartments.Items.Remove(item.Tag);
item.Tag =
null;
}
}
private void radTreeViewDepartments_PreviewUnchecked(object sender, RadRoutedEventArgs e)
{
RadTreeViewItem item = e.OriginalSource as RadTreeViewItem;
//Check if it's not the active tab, if it's the active tab, the routedevent was stop.
if (item != null && !item.HasItems && item.Tag != null)
{
if (item.Tag == RadTabControlDepartments.Items[RadTabControlDepartments.SelectedIndex])
{
e.Handled =
true;
}
}
}
If the subitem "1.1" correspond the my active tab in my RadTabControl and the user unchecked the subitem "1" in my RadTreeView, both subitems "1.2" and "1.3" become unchecked and the subitem "1.1" stay checked but the subtiem "1" become unchecked to indicate me that all the subitems should be unchecked!!!
If I try to unchecked subitems "1.3", "1.2" and "1.1" manually, of course subitem "1.1" stay checked and the state of the subitem "1" stay correct!!!
Thank's