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

TreeView Getting Started

2 Answers 27 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Nicola
Top achievements
Rank 1
Nicola asked on 23 Oct 2019, 05:34 PM

Hi everybody. Im following the getting started guide here (https://docs.telerik.com/devtools/xamarin/controls/treeview/treeview-getting-started). I have a few question: First of all I need to create the class Item and ViewModel in the general folder of the project?

Then when I arrived at this step:

<telerikDataControls:RadTreeView x:Name="treeView" ItemsSource="{Binding Source}"><telerikDataControls:TreeViewDescriptor DisplayMemberPath="Name"ItemsSourcePath="Children"TargetType="{x:Type local:Item}" /></telerikDataControls:RadTreeView>

If I copy this inside my project and then compile I get this error: "Type Item not found in xmlns" at row 13 that is this line here TargetType="{x:Type local:Item}
What am I doing wrong?

I just want to put a treeview in the app but Im not able. I tried to create the classes under UWP files, I moved all down there, delete from the main Shared part of the project but nothing.
Images attached :D
Thank you

 

 

2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 24 Oct 2019, 01:23 PM

Hi Nicola,

Thank you for your interest in RadTreeView for Xamarin.

In the example "local" refers to the namespace where Item class is placed - it is not specified as it can be different for different projects.

For example, if Item class is defined like this:

using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace GettingStartedExample
{
    public class Item
    { 
        public Item(string name)
        {
            this.Name = name;
            this.Children = new ObservableCollection<Item>();
        }

        public string Name { get; set; }
        public IList<Item> Children { get; set; }
    }
}

then in order to reference it like this:

<telerikDataControls:RadTreeView x:Name="treeView" ItemsSource="{Binding Source}">
            <telerikDataControls:TreeViewDescriptor DisplayMemberPath="Name"
                                                    ItemsSourcePath="Children"
                                                    TargetType="{x:Type local:Item}" />
</telerikDataControls:RadTreeView>

You would need to add the namespace to the ContentPage/ContentView:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:telerikDataControls="clr-namespace:Telerik.XamarinForms.DataControls;assembly=Telerik.XamarinForms.DataControls"
             xmlns:local="clr-namespace:GettingStartedExample"
             x:Class="GettingStartedExample.TreeViewGettingStartedXaml">

You can find the complete RadTreeView GettingStarted example in our SDKBrowser example github repo, here is the direct link:

https://github.com/telerik/xamarin-forms-sdk/tree/master/XamarinSDK/SDKBrowser/SDKBrowser/Examples/TreeViewControl/GettingStartedCategory/GettingStartedExample

I hope I was of help. 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
0
Nicola
Top achievements
Rank 1
answered on 25 Oct 2019, 11:19 AM
Super helpful. Thank you so much!
Tags
TreeView
Asked by
Nicola
Top achievements
Rank 1
Answers by
Yana
Telerik team
Nicola
Top achievements
Rank 1
Share this question
or