Expand or collapse specific node in treeview by code

1 Answer 56 Views
TreeView
Sven
Top achievements
Rank 1
Sven asked on 21 Jul 2023, 02:54 PM

Hello there!

I would like to know how I can expand/collapse a single node in the treeview by code. Can anybody help me?
And also if there is a chance to get notified in case of expanse/collapse (OnExpand event)

thanks a lot

regards

Sven

1 Answer, 1 is accepted

Sort by
0
Lance | Senior Manager Technical Support
Telerik team
answered on 21 Jul 2023, 03:29 PM

Hi Sven,

Currently these options are not available, you can get a better understanding of this by reviewing the following documentation article => Migrating the TreeView from Xamarin.Forms to .NET MAUI - Telerik UI for .NET MAUI.

Specifically, see that the Expand() and Collapse() methods have no .NET MAUI equivalent right now. The same is also true for the ItemExpanded and ItemCollapsed events.

Note that this is the first iteration of the control and we are adding more features as time goes on. To help prioritize certain features over others, I have opened the following dedicated Feature Requests:

 Note: You are already subscribed to the items, and I have added your upvote, so there is no further action needed on your part.

As for an alternate approach for the events, you can consider use the ItemTapped event and read the value of the node to gather needed information => .NET MAUI TreeView Documentation - Events.

Regards,
Lance | Manager Technical Support
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Sven
Top achievements
Rank 1
commented on 24 Jul 2023, 09:15 AM

I already encountered that there is no Expand method. But maybe there is a workaround by directly modifiyng the visible elements? If I define Items in XAML I can set them to expanded style. If this is possible, it should somehow be possible in code to I think?
Didi
Telerik team
commented on 24 Jul 2023, 09:21 AM

Hi Sven,

There are methods for expanding/collapsing all items, not a single item. I see that you have logged two features for this:

methods for expand/collapse item https://feedback.telerik.com/maui/1617134-treeview-add-expand-and-collapse-methods-for-items 

events for this: https://feedback.telerik.com/maui/1617136-treeview-add-itemexpanded-and-itemcollapsed-events 

There isn't a workaround I can suggest for this. The features must be implemented in the control.

Tags
TreeView
Asked by
Sven
Top achievements
Rank 1
Answers by
Lance | Senior Manager Technical Support
Telerik team
Share this question
or