We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

TreeVewAdv Selection issues

Hello,

I have a TreeViewAdv control that supports multi-selection and there is particular a scenario where I want to set a single item in the tree as selected when the user performs a certain action. I do this through two way binding to the SelectedTreeItem. There are two issues i'm having that I need help with:

1) The style when I set the selected item via two way binding is different than when I select it from the TreeViewAdv control. I need these to be the same.

2) When I set the selected item via the binding to SelectedTreeItem, in some cases it keeps other items selected as well. I've tired clearing the selected items collection but it seems to keep multiple items selected.

I have attached a sample solution similar to how I have the TreeViewAdv setup. Regarding 2) If you click one of the buttons twice and then a different button you can reproduce the issue, but it does happen in other scenarios as well.

Can you please help?

Thanks,

Hayley

Attachment: WPF_TreeViewAdv_1c9f8982.zip

1 Reply

JP Jagadeesan Pichaimuthu Syncfusion Team August 30, 2019 07:06 PM UTC

Hi Hayley, 

Thanks for using Syncfusion product. 

Query 
Details 
When I set the selected item via the binding to SelectedTreeItem, in some cases it keeps other items selected as well. I've tired clearing the selected items collection but it seems to keep multiple items selected. 
You can resolve this issue by modify the code with below code snippet. 

private void Node1_Click(object sender, RoutedEventArgs e) 
{ 
    if (CanClear("Node 1")) 
    { 
        return; 
    } 
    else 
    { 
        ClearSelection(); 
        ((MainWindowViewModel)this.DataContext).SelectNode("Node 1"); 
    } 
} 


Please refer the below modified sample for your reference. 
The style when I set the selected item via two way binding is different than when I select it from the TreeViewAdv control. I need these to be the same. 
We can able to see the reported problem in our end. We suspect, when select the item using the two way binding the selected background value is taken from the default style. You can resolve this issue by overriding the control template in App.Xaml file. Otherwise you can customize the item style by setting the item container style. Please refer the below UG and kb documentations for your reference. 



Regards, 
Jagadeesan 


Loader.
Live Chat Icon For mobile
Up arrow icon