{"id":23061414,"url":"https://github.com/syncfusionexamples/binding-rest-service-data-listview-xamarin","last_synced_at":"2026-05-06T22:09:27.118Z","repository":{"id":98094608,"uuid":"296025905","full_name":"SyncfusionExamples/binding-rest-service-data-listview-xamarin","owner":"SyncfusionExamples","description":"This repository contains sample about  how to bind the ListView data using RESTful API service in Xamarin.Forms (SfListView)","archived":false,"fork":false,"pushed_at":"2024-06-04T11:14:54.000Z","size":557,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-08T20:48:08.773Z","etag":null,"topics":["http-client","json","json-data","listview","restful-api","sflistview","xamarin","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-09-16T12:29:00.000Z","updated_at":"2024-06-04T11:14:58.000Z","dependencies_parsed_at":"2024-02-15T08:24:23.515Z","dependency_job_id":"d0edbc61-7cab-41ff-9537-774eb9f840cc","html_url":"https://github.com/SyncfusionExamples/binding-rest-service-data-listview-xamarin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fbinding-rest-service-data-listview-xamarin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fbinding-rest-service-data-listview-xamarin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fbinding-rest-service-data-listview-xamarin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fbinding-rest-service-data-listview-xamarin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SyncfusionExamples","download_url":"https://codeload.github.com/SyncfusionExamples/binding-rest-service-data-listview-xamarin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246952281,"owners_count":20859813,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["http-client","json","json-data","listview","restful-api","sflistview","xamarin","xamarin-forms"],"created_at":"2024-12-16T03:17:25.530Z","updated_at":"2026-05-06T22:09:22.086Z","avatar_url":"https://github.com/SyncfusionExamples.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to bind the ListView data using RESTful API service in Xamarin.Forms (SfListView)\n\nThe Xamarin.Forms [SfListView](https://help.syncfusion.com/xamarin/listview/overview) supports to populate the fetched data from REST services. Refer Xamarin.Forms document about consuming RESTful web service before reading this [article](https://docs.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/consuming/rest).\n\nYou can also refer the following article.\n\nhttps://www.syncfusion.com/kb/11932/how-to-bind-the-listview-data-using-restful-api-service-in-xamarin-forms-sflistview\n\nPlease refer to the following steps to implement SfListView with REST services,\n\n**STEP 1: Create Xamarin.Forms application with SfListView**\n\nDefine **SfListView** bound to the ViewModel collection.\n\n``` xml\n\u003cContentPage xmlns=\"http://xamarin.com/schemas/2014/forms\"\n             xmlns:x=\"http://schemas.microsoft.com/winfx/2009/xaml\"\n             xmlns:local=\"clr-namespace:ListViewXamarin\"\n             xmlns:syncfusion=\"clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms\"\n             x:Class=\"ListViewXamarin.MainPage\"\u003e\n    \u003cContentPage.BindingContext\u003e\n        \u003clocal:ContactsViewModel/\u003e\n    \u003c/ContentPage.BindingContext\u003e\n\t \u003cContentPage.Content\u003e\n        \u003cStackLayout\u003e\n            \u003csyncfusion:SfListView x:Name=\"listView\" AutoFitMode=\"Height\" ItemSpacing=\"5\" ItemsSource=\"{Binding UserInfo}\"\u003e\n                \u003csyncfusion:SfListView.ItemTemplate \u003e\n                    \u003cDataTemplate\u003e\n                        \u003cFrame HasShadow=\"True\" \u003e\n                            \u003cGrid\u003e\n                                \u003cGrid.RowDefinitions\u003e\n                                    \u003cRowDefinition Height=\"Auto\"/\u003e\n                                    \u003cRowDefinition Height=\"Auto\"/\u003e\n                                    \u003cRowDefinition Height=\"Auto\"/\u003e\n                                    \u003cRowDefinition Height=\"Auto\"/\u003e\n                                \u003c/Grid.RowDefinitions\u003e\n                                \u003cLabel Grid.Row=\"0\" Text=\"{Binding [username]}\" HorizontalOptions=\"Start\" TextColor=\"Black\" FontSize=\"16\" /\u003e\n                                \u003cLabel Grid.Row=\"1\" Text=\"{Binding [website]}\" HorizontalOptions=\"Start\" TextColor=\"Black\"/\u003e\n                                \u003cLabel Grid.Row=\"2\" Text=\"{Binding [phone]}\" HorizontalOptions=\"Start\" TextColor=\"Black\" FontSize=\"16\" FontAttributes=\"Bold\"/\u003e\n                                \u003cLabel Grid.Row=\"3\" Text=\"{Binding [email]}\" HorizontalOptions=\"Start\" TextColor=\"Black\" FontSize=\"16\" FontAttributes=\"Bold\"/\u003e\n                            \u003c/Grid\u003e\n                        \u003c/Frame\u003e\n                    \u003c/DataTemplate\u003e\n                \u003c/syncfusion:SfListView.ItemTemplate\u003e\n            \u003c/syncfusion:SfListView\u003e\n        \u003c/StackLayout\u003e\n    \u003c/ContentPage.Content\u003e\n\u003c/ContentPage\u003e\n```\n\n**STEP 2:** Install the [ModernHttpClient](https://www.nuget.org/packages/modernhttpclient/) and [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json/) NuGet packages in the shared code project.\n\n**STEP 3: Retrieve data from the REST service**\n\nDefine [HTTPClient](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.getasync?view=netcore-3.1) to retrieve the information from the webservice for a specified url using [GetAsync](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.getasync) method. You can read the retrieved data to string format using[HTTPContent.ReadAsStringAsync](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.readasstringasync?view=netcore-3.1) method. Using, [JsonConvert.DeserializeObject](https://www.newtonsoft.com/json/help/html/Overload_Newtonsoft_Json_JsonConvert_DeserializeObject.htm) method, convert the JSON string to dynamic .\n\n``` c#\nnamespace ListViewXamarin\n{\n    /// \u003csummary\u003e\n    /// Implementation of RestService to be displayed.\n    /// \u003c/summary\u003e\n    public class RestService\n    { \n        System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();\n\n        public dynamic Items { get; private set; }\n\n        public string RestUrl { get; private set;  }\n\n        public RestService()\n        {\n            RestUrl = \"https://jsonplaceholder.typicode.com/users\"; // Set your REST API url here\n            client = new HttpClient();\n        }\n\n        public async Task\u003cdynamic\u003e GetDataAsync()\n        {\n            try\n            {\n                //Sends request to retrieve data from the web service for the specified Uri\n                var response = await client.GetAsync(RestUrl);\n\n                if (response.IsSuccessStatusCode)\n                {\n                    var content = await response.Content.ReadAsStringAsync(); //Returns the response as JSON string\n                    Items = JsonConvert.DeserializeObject\u003cdynamic\u003e(content); //Converts JSON string to dynamic\n                }\n            }\n            catch (Exception ex)\n            {\n                 Debug.WriteLine(@\"ERROR {0}\", ex.Message);\n            }\n            return Items;\n        }\n    }\n}\n```\n**STEP 4: Populate data to collection**\n\nIn the ViewModel class, initialize the **RestService** and populate data by invoking the **GetDataAsync** method and set to the collection which bound to the **SfListView**.\n\n```c#\nusing System;\nusing System.Collections.Generic;\nusing System.Collections.ObjectModel;\nusing System.ComponentModel;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Xamarin.Forms;\n\nnamespace ListViewXamarin\n{\n    public class ContactsViewModel : INotifyPropertyChanged\n    {\n        private dynamic userInfo;\n\n        public static RestService DataServices { get; private set; }\n\n        public dynamic UserInfo\n        {\n            get { return userInfo; }\n            set\n            {\n                userInfo = value;\n                RaisedOnPropertyChanged(\"UserInfo\");\n            }\n        }\n\n        public ContactsViewModel()\n        {\n            DataServices = new RestService();\n\n            //Gets data from REST service and set it to the ItemsSource collection\n            RetrieveDataAsync();\n        }\n\n        public async void RetrieveDataAsync()\n        {\n            UserInfo = await DataServices.GetDataAsync();\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyncfusionexamples%2Fbinding-rest-service-data-listview-xamarin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyncfusionexamples%2Fbinding-rest-service-data-listview-xamarin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyncfusionexamples%2Fbinding-rest-service-data-listview-xamarin/lists"}