Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syncfusionexamples/xamarin-datasource-getting-started
Demo application shows to create a sample using Xamarin.Forms DataSource.
https://github.com/syncfusionexamples/xamarin-datasource-getting-started
datasource xamarin xamarin-forms
Last synced: 27 days ago
JSON representation
Demo application shows to create a sample using Xamarin.Forms DataSource.
- Host: GitHub
- URL: https://github.com/syncfusionexamples/xamarin-datasource-getting-started
- Owner: SyncfusionExamples
- Created: 2019-01-22T12:34:25.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-15T13:41:36.000Z (11 months ago)
- Last Synced: 2024-04-14T12:07:22.315Z (9 months ago)
- Topics: datasource, xamarin, xamarin-forms
- Homepage:
- Size: 2.3 MB
- Stars: 0
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Xamarin DataSource
## About the sample
Demo application shows to create a sample using Xamarin.Forms DataSource.
Create new BlankApp (Xamarin.Forms.Portable) application in Xamarin Studio or Visual Studio. Import the DataSource namespace Syncfusion.DataSource and set the source for the DataSource by using the DataSource.Source property. You can bind the DataSource.DisplayItems as ItemsSource for any data bound control.
```C#
using Syncfusion.DataSource;public App()
{
DataSource dataSource = new DataSource();
dataSource.Source = new ContactsList();
}
```
Create a data model to bind it to the DisplayItems.
```C#
public class Contacts : INotifyPropertyChanged
{
private string contactName;public Contacts(string name)
{
contactName = name;
}public string ContactName
{
get { return contactName; }
set
{
if (contactName != value)
{
contactName = value;
this.RaisedOnPropertyChanged("ContactName");
}
}
}public event PropertyChangedEventHandler PropertyChanged;
public void RaisedOnPropertyChanged(string _PropertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(_PropertyName));
}
}
}
```
Create a model repository class with required number of data objects.```C#
public class ContactsList : ObservableCollection, INotifyPropertyChanged
{
public ContactsList()
{
foreach (var customerName in CustomerNames)
{
var contact = new Contacts(customerName);
this.Add(contact);
}
}
string[] CustomerNames = new string[] {
"Kyle",
"Gina",
"Irene",
"Katie",
"Michael",
"Oscar",
"Ralph",
"Torrey",
"William",
"Bill",
"Daniel",
"Frank",
"Brenda",
"Danielle",
"Fiona",
"Howard",
"Jack",
"Larry",
};
}
```## Requirements to run the demo ##
* [Visual Studio 2017](https://visualstudio.microsoft.com/downloads/) or [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/).
* Xamarin add-ons for Visual Studio (available via the Visual Studio installer).## Troubleshooting ##
### Path too long exception
If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project.