Declined
Last Updated: 06 Jan 2020 10:00 by ADMIN
Bruce
Created on: 20 Dec 2019 17:14
Category: TreeView
Type: Bug Report
2
Treeview not defaulting to non-expanded items

The documentation notes that the TreeView should have its items default as IsExpanded=False, however, everything is expanded when I start my TreeView. This also includes the situation when I have a TreeView with a custom template (provided by the excellent people at Telerik, for dealing with cutoff expander icon issue!) and if I try to set Expanded explicitly to False via the template and viewmodel.

This seems to be pretty basic and I have to wonder if I'm not doing something correctly.

Thanks. 

5 comments
ADMIN
Yana
Posted on: 06 Jan 2020 10:00

Hello Bruce,

I am afraid the only way to collapse all items of the TreeView is through CollapseAll method - it should be called when the control is about to be visualized. For example, you can use NativeControlLoaded event of the TreeView and inside its handler get the TreeView reference and call the method.

Please give it a try and let me know whether this helps.

Regards,
Yana
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Bruce
Posted on: 02 Jan 2020 14:04
The tree comes out fully expanded no matter what. Is there any way to have it initialized as having all the nodes collapsed? Is it possible only through code-behind during form initialization?
ADMIN
Yana
Posted on: 26 Dec 2019 08:00

Hello Bruce,

I understand what you're trying to achieve - you'd like to bind IsExpanded property inside the template to a property in your ViewModel and set it from there.  I am afraid that wouldn't be possible with the current implementation of the TreeView - the expanded/collapsed state of the items could be controlled only through the provided by the TreeView Expand/Collapse methods . That expand/collapse mechanism is implemented in that way, that the items' state is switched either by user interaction or through the methods, direct binding wouldn't work.

We have a feature request regarding this, you can cast your vote and follow its status at the link below:
TreeView: Provide a way to expand/collapse items in a MVVM manner

In addition, by default the items are expanded,  I couldn't find in the documentation where we stated it's the other way,  if I am missing it, please let me know the exact topic, so I can fix it right away.

As a workaround, you can initially collapse all nodes (through CollapseAll method) and then traverse the items and manually expand the ones according to their IsExpanded property.  You can also have an additional collection to preserve the expanded nodes.  I understand this is not so straightforward approach and that it requires implementing additional logic, still, at the moment, that's the only way I could suggest.

I am sorry for any inconvenience caused. Let me know if you have any additional questions or concerns.

Regards,
Yana
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Bruce
Posted on: 23 Dec 2019 14:06

I believe your documentation states that the default for the Treeview would be for all its items to be collapsed by default, correct? That's not happening. I'm currently utilizing a solution that your team assisted us with for a workaround for a graphical glitch (https://www.telerik.com/forums/expander-icon-getting-cut-off) and if even I set the IsExpanded=False in the ExpandCollapseIndicator node, it's ignored. I tried this after trying to force that value to False via MVVM.

Perhaps I'm doing something incorrectly in trying to set that value (which is definitely my M.O. more often than not...lol!).

ADMIN
Sisi
Posted on: 23 Dec 2019 12:24

Hi Bruce,

I am sorry to hear about the situation you have to deal with.

I would need more information on your exact setup in order to investigate further. Could you please elaborate more on the scenario you wish to achieve? For example all treeview items should be collapsed by default or a particular item? 

In case you want to collapse all items, more info can be found in our help topic here: https://docs.telerik.com/devtools/xamarin/controls/treeview/treeview-expand-collapse

Could you please send me some screenshots on how the treeview should look?

I am looking forward to your reply.

Happy holidays!

Regards,
Sisi
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items