Skip to content

This repository contains a sample on How to bind JSON online data to the Syncfusion Xamarin.Forms Schedule (SfSchedule) control?

Notifications You must be signed in to change notification settings

SyncfusionExamples/appointment-json-online-schedule-xamarin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to bind JSON online data to Xamarin.Forms Schedule (SfSchedule)

You can bind data from JSON to the Xamarin forms SfSchedule appointments.

You can also refer the following article.

https://www.syncfusion.com/kb/11931/how-to-bind-json-online-data-to-xamarin-forms-schedule-sfschedule

STEP 1: Create a JSON data model

public class JSONData
{
    public string Subject { get; set; }
    public string StartTime { get; set; }
    public string EndTime { get; set; }
}

STEP 2: Get the online JSON data with the help of GetStringAsync method and Deserialize the JSON data as list of JSON data mode and then Add the JSON data list into the appointment collection ( Meetings ).

private async void GetInformation()
{
    var httpClient = new HttpClient();
    var response = await httpClient.GetStringAsync("https://js.syncfusion.com/demos/ejservices/api/Schedule/LoadData");
    jsonDataCollection = JsonConvert.DeserializeObject<List<JSONData>>(response);
    this.Meetings = new ObservableCollection<Meeting>();
    foreach (var data in jsonDataCollection)
    {
        Meetings.Add(new Meeting()
        {
            EventName = data.Subject,
            From = Convert.ToDateTime(data.StartTime),
            To = Convert.ToDateTime(data.EndTime),
            Color = Color.Red
        });
    }
}

STEP 3: Bind appointments that collected through JSON online it to a schedule using the SfSchedule.DataSource property.

<schedule:SfSchedule x:Name="Schedule"
                    DataSource="{Binding Meetings}"
                    ScheduleView="MonthView" MoveToDate="{Binding dateTime}" ShowAppointmentsInline="True"
                    >
    <schedule:SfSchedule.AppointmentMapping>
        <schedule:ScheduleAppointmentMapping
        EndTimeMapping="To"
        StartTimeMapping="From"
        SubjectMapping="EventName"
        ColorMapping="Color"
        />
    </schedule:SfSchedule.AppointmentMapping>
    <schedule:SfSchedule.BindingContext>
        <local:SchedulerViewModel/>
    </schedule:SfSchedule.BindingContext>
</schedule:SfSchedule>

Output

JSONSchedule

About

This repository contains a sample on How to bind JSON online data to the Syncfusion Xamarin.Forms Schedule (SfSchedule) control?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages