- Home
- Forum
- Xamarin.Forms
- Binding CalendarEvents to my own Model
Binding CalendarEvents to my own Model
Hi
Im using the SFCalendar for the first time and am a very inexperienced dev.
I have a WEBAPI that returns data from the GET message in an observable collection of type 'Shift;
public class Shift
{
[PrimaryKey, AutoIncrement]
public int ID { get; set; }
public DateTime WI_Date { get; set; }
public DateTime WI_Start_Time { get; set; }
public DateTime WI_End_Time { get; set; }
public int Practice { get; set; }
public string Rate { get; set; }
public string Paid { get; set; }
public string Revenue { get; set; }
}
I wish to use the SFCalendar to display all the 'shift' records returned from the API..
but im struggling to bind and this is very new to me..
Essentially I wish to data bind to the returning ObervableCollection <Shift> whilst essentially mapping the SFCalendar Event properties ( Start Time, End Time, Subject) to the properties in my data:
So ....
SFCalendar Start Time to bind to Shift WI_Start_Time
SFCalendar End Time to bind to Shift WI_End_Time
SFCalendar Subject to bind to Shift Practice
Any ideas? Example Code please??
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
CH
Chris
November 10, 2020 07:11 PM UTC
Even if I drop the auto binding and loop through my Observable collection..
My Events are all being added to the same date - despite the Start & end Date properties being set correctly..:
public ObservableCollection ObjChartData;
public CalendarEventCollection EventsCollection = new CalendarEventCollection();
public CalendarInlineEvent Event = new CalendarInlineEvent();
while (x <= ObjChartData.Count - 1)
{
Event.StartTime = ObjChartData[x].WI_Start_Time.Date;
Event.EndTime = ObjChartData[x].WI_End_Time.Date;
Event.Subject = ObjChartData[x].Name;
Event.Color = Color.DarkBlue;
EventsCollection.Add(Event);
x = x + 1;
}
//Add collection of events as source of SfCalendar
calendar.DataSource = EventsCollection;
i know my Observable collection is correct ( i can loop through in Debug) for some reason they are just all being added to the calendar with the same date - which happens to be the Start & Date Date of the last record in my collection..
*Sorry should have also mentioned I added the Name property in my Shift model to be used as the subject (instead of Practice)
Any ideas?
Marked as answer
CH
Chris
November 11, 2020 11:04 AM UTC
Ignore issue - was a Data Error in the DB
SS
SaiGanesh Sakthivel
Syncfusion Team
November 11, 2020 01:39 PM UTC
Hi Chris,
Thank you for the update.
We are glad to know that the reported issue is resolved. Please let us know if you need any further assistance.
Regards,
SaiGanesh Sakthivel
SIGN IN To post a reply.