From 30d4d1a53487563caf3e38c5516121cd4a33bf10 Mon Sep 17 00:00:00 2001 From: Anandh-SF4665 Date: Wed, 10 Sep 2025 18:06:37 +0530 Subject: [PATCH] Updated the README.md file --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/README.md b/README.md index 3d13509..0afc71f 100644 --- a/README.md +++ b/README.md @@ -1 +1,68 @@ **[View document in Syncfusion .NET MAUI Knowledge Base](https://www.syncfusion.com/kb/13128/how-to-bind-data-from-the-datatable-to-net-maui-listview-sflistview)** + +## Sample + +```xaml + + + + + + + + + + + + + + + + + + + + + +ViewModel.cs: + +public ObservableCollection ContactsInfo { get; set; } + +public ContactsViewModel() +{ + GenerateInfo(); +} + +private void GenerateInfo() +{ + Random random = new Random(); + + ContactsInfo = new ObservableCollection(); + + DataTable dt = new DataTable("Contacts"); + dt.Columns.Add("ContactID", typeof(Int32)); + dt.Columns.Add("ContactName", typeof(string)); + dt.Columns.Add("ContactType", typeof(string)); + dt.Columns.Add("ContactNumber", typeof(string)); + + for (int i = 0; i < CustomerNames.Count(); i++) + { + dt.Rows.Add(i + 1, CustomerNames[i], contactType[random.Next(0, 5)], random.Next(100, 400).ToString() + "-" + random.Next(500, 800).ToString() + "-" + random.Next(1000, 2000).ToString()); + } + + for (int i = 0; i < dt.Rows.Count; i++) + { + ContactsInfo.Add(dt.Rows[i]); + } +} +``` \ No newline at end of file