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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

TreeVewAdv Selection issues

Thread ID:

Created:

Updated:

Platform:

Replies:

147023 Aug 29,2019 04:37 AM UTC Aug 30,2019 07:06 PM UTC WPF 1
loading
Tags: TreeViewAdv
Hayley Miller
Asked On August 29, 2019 04:37 AM UTC

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

Jagadeesan Pichaimuthu [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon