Xamarin-Forms-TreeView icon indicating copy to clipboard operation
Xamarin-Forms-TreeView copied to clipboard

Multiple Root

Open satopcu opened this issue 8 years ago • 3 comments

How to add other roots ? Thank you.

satopcu avatar Oct 18 '16 21:10 satopcu

did you ever figure this out?

zanesc avatar Nov 01 '16 13:11 zanesc

A tree structure can only have one root, but it's possible one could write a modification that would let you pick at what level of the tree to start rendering visibly: "hide level 0, draw level 1 and higher", etc.

These kinds of code contributions are welcome!

danvanderboom avatar Nov 01 '16 17:11 danvanderboom

HSoshiant's branch can do this. In your TreeView, define your HeaderCreationFactory as follows:

HeaderCreationFactory =
                (node) =>
                {
                    ContentView result;
                    if (node.Depth == 0) //do not show the root node
                    {
                        result = new ContentView();
                    }
                    else
                    {
                        result = new MyTreeCardView
                        {
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions = LayoutOptions.Start
                        };
                        Debug.WriteLine("HeaderCreationFactory: new MyTreeCardView");
                    }
                    return result;
                };

DinnerBuffet avatar Nov 23 '17 06:11 DinnerBuffet