This is a migrated thread and some comments may be shown as answers.

IsSynchronizedWithCurrentItem not working as expected

4 Answers 1030 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Sieglinde
Top achievements
Rank 1
Sieglinde asked on 01 Feb 2019, 02:52 PM

Using v2018-03:

According to https://docs.telerik.com/devtools/wpf/controls/radgridview/troubleshooting/first-row-always-selected I have to set IsSynchronizedWithCurrentItem =False when I don't want the first element to be selected automatically. Doing this the variable the SelectedItem is bound to is not overwritten, this is good. But the element referenced by SelectedItem is not highlighted in the tree. I need the tree to highlight the item referenced in SelectedItem as it was before the TreeListView instantiated.

 

Thanks in advance!

4 Answers, 1 is accepted

Sort by
0
Sieglinde
Top achievements
Rank 1
answered on 01 Feb 2019, 08:34 PM

Problem is the same as https://www.telerik.com/forums/tree-will-not-expand-to-selection-unless-it-has-been-expanded-to-the-level-previously - it does select the first element if the SelectedItem has not been expanded.

Using AutoExpandItems works but is ugly as only the path to the SelectedItem should be expanded.
Is there any fix for this that does not involve creating additional paths and/or calling SelectItemByPath? As the control is used in a dialog which receives a preset viewModel.
E.g. an event listener that can collapse all paths and keep only the selected item open that is called after the control rendered? DataLoaded seems to be to early, SelectionChanged triggers for all changes which is undesired.

Thank you!

0
Vladimir Stoyanov
Telerik team
answered on 06 Feb 2019, 11:19 AM
Hello Sieglinde,

Please, allow me to elaborate a bit on the IsSynchronizedWithCurrentItem property. When setting it to false, the selected item of the RadTreeListView will not be synced with the CurrentItem. By default the CurrentItem is the 1st one, so when they are synced the SelectedItem is also the 1st one. That said, by default the IsSynchronizedWithCurrentItem is set to null, meaning that the SelectedItem and CurrentItem will not be synced unless a CollectionView is used as ItemsSource.

That said, may I ask you to check out the Stop Showing the Unfocused State article in our documentation? Does setting the EnableLostFocusSelectedState to False help in your scenario?

If it does not, please share some sample pictures/videos of the current and the expected result so that I can better understand the scenario and further assist you.

Additionally, please note that the referenced forum topic: https://www.telerik.com/forums/tree-will-not-expand-to-selection-unless-it-has-been-expanded-to-the-level-previously is for the RadTreeView control and not the RadTreeListView. Note, that  they are separate controls with different functionality and the provided suggestions may not be suitable for your scenario.

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Sieglinde
Top achievements
Rank 1
answered on 16 Feb 2019, 05:13 PM

Got it working by changing how I set the selected item (by selecting from the ObservableCollection which is the itemsource instead from the collection whose elements are then added to the ObservableCollection).

Still the behaviour of auto-selecting the first Item on render when no selectedItem is set is troubleing as I can later set the selecteItem to null without a problem. Is there any switch to prevent this?

It causes problems when the tree is used in a dialog to edit an item where the tree contains possible parents or other references but the item had none selected before. When the tree autoselects the first element and the user does not notice this it would set the parent/reference unintentionally.

0
Vladimir Stoyanov
Telerik team
answered on 19 Feb 2019, 01:01 PM
Hello Sieglinde,

Thank you for the update.

My current understanding is that after setting the IsSynchronizedWithCurrentItem property to False and then programmatically setting the SelectedItem, the RadTreeListView is not visually not updated. Feel free to correct me if that is not the case and provide some more details about the exact scenario. 

I tested the above scenario in a sample project, however I was not able to reproduce it. That is why I am attaching the project which I used for testing purposes. Please, check it out and let me know if it helps. 

Should you need any further assistance, please share a video demonstrating the observed on your end behavior and let me know if I can reproduce the same scenario in the sample project (perhaps with some modifications). This way I will be able to better understand the scenario and hopefully further assist you. 

I am looking forward to your reply.

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TreeListView
Asked by
Sieglinde
Top achievements
Rank 1
Answers by
Sieglinde
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Share this question
or