{"id":23061432,"url":"https://github.com/syncfusionexamples/json-treeview-xamarin","last_synced_at":"2026-05-17T19:37:25.203Z","repository":{"id":98095976,"uuid":"308282741","full_name":"SyncfusionExamples/json-treeview-xamarin","owner":"SyncfusionExamples","description":"This repository contains the sample about how to bind JSON data to Xamarin.Forms TreeView (SfTreeView)","archived":false,"fork":false,"pushed_at":"2024-05-28T13:15:44.000Z","size":1270,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-29T03:49:30.819Z","etag":null,"topics":["json","json-data","treeview","xamarin-forms"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SyncfusionExamples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-29T09:45:45.000Z","updated_at":"2024-05-28T13:15:48.000Z","dependencies_parsed_at":"2025-02-08T20:45:34.818Z","dependency_job_id":"d4f14f27-f37d-4e6d-b394-093df4afa8f4","html_url":"https://github.com/SyncfusionExamples/json-treeview-xamarin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SyncfusionExamples/json-treeview-xamarin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fjson-treeview-xamarin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fjson-treeview-xamarin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fjson-treeview-xamarin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fjson-treeview-xamarin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SyncfusionExamples","download_url":"https://codeload.github.com/SyncfusionExamples/json-treeview-xamarin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fjson-treeview-xamarin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33152062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","json-data","treeview","xamarin-forms"],"created_at":"2024-12-16T03:17:29.303Z","updated_at":"2026-05-17T19:37:25.183Z","avatar_url":"https://github.com/SyncfusionExamples.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to bind JSON data to Xamarin.Forms TreeView (SfTreeView)\n\nYou can bind the data from [JSON](http://www.json.org/) (JavaScript Object Notation) file to the Xamarin forms [SfTreeView](https://help.syncfusion.com/xamarin/treeview/getting-started?) using [ItemSource](https://help.syncfusion.com/cr/xamarin/Syncfusion.XForms.TreeView.SfTreeView.html?_ga=2.169034657.1409646585.1603702470-522025424.1599212225#Syncfusion_XForms_TreeView_SfTreeView_ItemsSource) property.\n\nYou can also refer our article from Syncfusion KnowledgeBase\n\nhttps://www.syncfusion.com/kb/12002/how-to-bind-json-data-to-xamarin-forms-treeview-sftreeview\n\n**STEP 1:** Create a JSON data model\n\n``` c#\npublic class Cities\n{\n    public string Name { get; set; }\n}\n\npublic class States\n{\n    public List\u003cCities\u003e Cities { get; set; }\n    public string Name { get; set; }\n}\n\npublic class Countries\n{\n    public List\u003cStates\u003e States { get; set; }\n    public string Name { get; set; }\n}\n``` c#\n**STEP 2:** Accessed the JSON file from local folder and use [StreamReader](https://docs.microsoft.com/en-us/dotnet/api/system.io.streamreader?view=netcore-3.1) to reads the data and return as a ObservableCollection property.\n\n``` c#\nprivate void GenerateSource()\n{\n    var assembly = typeof(MainPage).GetTypeInfo().Assembly;\n    Stream stream = assembly.GetManifestResourceStream(\"TreeViewXamarin.Data.navigation.json\");\n    using (StreamReader sr = new StreamReader(stream))\n    {\n        var jsonText = sr.ReadToEnd();\n        ImageNodeInfo = new ObservableCollection\u003cCountries\u003e();\n        var MyArrayData = JsonConvert.DeserializeObject\u003cList\u003cCountries\u003e\u003e(jsonText);\n        foreach (var data in MyArrayData)\n        {\n            ImageNodeInfo.Add(data);\n        }\n    }\n}\n``` \n**STEP 3:** Bind the JSON collection data to the SfTreeView ItemSource.\n``` xml\n\u003csyncfusion:SfTreeView x:Name=\"treeView\"\n                       ItemHeight=\"40\"\n                       Indentation=\"30\"\n                       ExpanderWidth=\"20\"              \n                       ItemsSource=\"{Binding ImageNodeInfo}\" \n                       AutoExpandMode=\"RootNodesExpanded\" NodePopulationMode=\"Instant\"\u003e\n    \u003csyncfusion:SfTreeView.HierarchyPropertyDescriptors\u003e\n        \u003csyncfusion1:HierarchyPropertyDescriptor TargetType=\"{x:Type local:Countries}\" ChildPropertyName=\"States\"/\u003e\n        \u003csyncfusion1:HierarchyPropertyDescriptor TargetType=\"{x:Type local:States}\" ChildPropertyName=\"Cities\"/\u003e\n    \u003c/syncfusion:SfTreeView.HierarchyPropertyDescriptors\u003e\n    \u003csyncfusion:SfTreeView.ItemTemplate\u003e\n        \u003cDataTemplate\u003e\n            \u003cViewCell\u003e\n                \u003cGrid x:Name=\"grid\" BackgroundColor=\"Transparent\"\u003e\n                    \u003cLabel LineBreakMode=\"WordWrap\"\n                                           Text=\"{Binding Name}\"\n                                           TextColor=\"Black\"\n                                           VerticalTextAlignment=\"Center\"/\u003e\n                \u003c/Grid\u003e\n            \u003c/ViewCell\u003e\n        \u003c/DataTemplate\u003e\n    \u003c/syncfusion:SfTreeView.ItemTemplate\u003e\n\u003c/syncfusion:SfTreeView\u003e\n```\n**Output**\n![JSONTreeViewXamarin](https://github.com/SyncfusionExamples/json-treeview-xamarin/blob/main/ScreenShots/JSONTreeViewXamarin.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyncfusionexamples%2Fjson-treeview-xamarin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyncfusionexamples%2Fjson-treeview-xamarin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyncfusionexamples%2Fjson-treeview-xamarin/lists"}