How to add or remove one TreeViewItem from its parent TreeViewItem? #15353
-
I am trying to manully add or remove a TreeViewItem from its parent TreeViewItem. In WPF, I can do such operation with following codes.
However, I tried many methods in Avalonia 11, still cannot find a right way to successfuly implement such operation. Sometimes it throws exception which says 'System.InvalidOperationException: The control already has a visual parent.'. Is there any path to solve the problem? This question took me a long time. Thanks in advanced if anyone can give any tips. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Better to use the MVVM pattern and use a TreeDataTemplate, see: https://docs.avaloniaui.net/docs/reference/controls/detailed-reference/treeview-1#example |
Beta Was this translation helpful? Give feedback.
TreeViewSample.zip