I have a RadTreeView where the SelectionMode = "Multiple". However, I only want nodes to remain selected if they are on the same level. For instance, if two nodes are selected on level 1 and a node on level 2 is selected, I want the two nodes on level 1 to be deselected and the only node to be selected is the node on level 2.
I read this Knowledge Base Article and implemented the ContainerBindingCollection. However, when I set the Selected property of the object in the SelectedItems collection of the Tree, the selected nodes still remain selected.
Below is the markup for the xaml:
Below is how I spin throw the SelectedItems collection and set the Selected property to false:
How can I deselect selected nodes?
Thanks,
Glenn
I read this Knowledge Base Article and implemented the ContainerBindingCollection. However, when I set the Selected property of the object in the SelectedItems collection of the Tree, the selected nodes still remain selected.
Below is the markup for the xaml:
<telerik:ContainerBindingCollection x:Name="BindingsCollection"> |
<telerik:ContainerBinding PropertyName="IsSelected" Binding="{Binding Selected, Mode=TwoWay}" /> |
<telerik:ContainerBinding PropertyName="IsExpanded" Binding="{Binding Expanded, Mode=TwoWay}" /> |
</telerik:ContainerBindingCollection> |
<telerik:HierarchicalDataTemplate |
x:Key="UserTemplate" |
telerik:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}"> |
<StackPanel Orientation="Horizontal"> |
<Image Source="Assets/Images/user.png"/> |
<TextBlock Margin="5,0,0,0" Text="{Binding UserName}" /> |
</StackPanel> |
</telerik:HierarchicalDataTemplate> |
<telerik:HierarchicalDataTemplate |
x:Key="MembershipTemplate" |
ItemTemplate="{StaticResource UserTemplate}" |
ItemsSource="{Binding User}" |
telerik:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}" > |
<StackPanel Orientation="Horizontal"> |
<Image Source="Assets/Images/pkg.png"/> |
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" /> |
</StackPanel> |
</telerik:HierarchicalDataTemplate> |
<telerik:HierarchicalDataTemplate |
x:Key="FacilityTemplate" |
ItemTemplate="{StaticResource MembershipTemplate}" |
ItemsSource="{Binding Membersip}" |
telerik:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}"> |
<StackPanel Orientation="Horizontal"> |
<Image Source="Assets/Images/house.png"/> |
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" /> |
</StackPanel> |
</telerik:HierarchicalDataTemplate> |
<telerik:HierarchicalDataTemplate |
x:Key="OrderTemplate" |
ItemTemplate="{StaticResource FacilityTemplate}" |
ItemsSource="{Binding Facility}" |
telerik:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}"> |
<StackPanel Orientation="Horizontal"> |
<Image Source="Assets/Images/book.png"/> |
<TextBlock Margin="5,0,0,0" Text="Order: " /><TextBlock Text="{Binding OrderNumber}" /> |
</StackPanel> |
</telerik:HierarchicalDataTemplate> |
Below is how I spin throw the SelectedItems collection and set the Selected property to false:
foreach (var obj in this.RadTreeView1.SelectedItems) { |
if (!obj.GetType().Equals(item.Header.GetType())) { |
((MyModelBase)obj).Selected = false; |
} |
} |
How can I deselect selected nodes?
Thanks,
Glenn