Hello Alex,
The Calendar has the ability for you to set an AppointmentsSource (just like ItemsSource for a ListView). If you follow the RadCalendar
Appointments tutorial, you'll see that you create an
Appointment object and then add it to the collection that is bound to AppointmentsSource.
Now, if you want the DataForm to be the control that creates the Appointment object, then just set the
DataForm.Source property using an instance of an
Appointment object. Please visit the
DataForm Getting Started Documentation to get started, instead of a
SourceItem model, you would use your Appointment model.
When the user is done editing that appointment in the DataForm, you call myDataForm.CommitAll() which saves the values to the Source. then finally you can add that appointment to the AppointmentsSource.
To address your request on this being "in real time" then just make sure you're using an ObservableCollection for the AppointmentSource. When you change any of the items in an ObservableCollection, anything bound to it will also be updated.
As a concept example, here's a Calendar next to a DataForm (note this will not fit on a mobile phone screen).
using
System;
using
System.Collections.ObjectModel;
using
Telerik.XamarinForms.Common.DataAnnotations;
using
Telerik.XamarinForms.Input;
using
Xamarin.Forms;
namespace
CalendarWithDataForm.Portable
{
public
partial
class
MainPage : ContentPage
{
public
ObservableCollection<Appointment> Appointments {
get
;
set
; } =
new
ObservableCollection<Appointment>();
public
MainPage()
{
InitializeComponent();
Appointments.Add(
new
Appointment
{
Title =
"Meeting with Tom"
,
Detail =
"Sea Garden"
,
StartDate = DateTime.Today.AddHours(1),
EndDate = DateTime.Today.AddHours(2),
Color = Color.Tomato
});
calendar.AppointmentsSource =
this
.Appointments;
dataForm.Source =
new
Appointment();
}
private
void
SaveAppointmentButton_OnClick(
object
sender, EventArgs e)
{
// Commit the values in the form to the Source object
dataForm.CommitAll();
// add the appointment to the Appointments collection
this
.Appointments.Add(dataForm.Source
as
Appointment);
// reset the DataForm so that you can add a new appointment
dataForm.Source =
null
;
dataForm.Source =
new
Appointment();
}
}
public
class
Appointment : IAppointment
{
[DisplayOptions(Header =
"Start Date"
)]
public
DateTime StartDate {
get
;
set
; }
[DisplayOptions(Header =
"End Date"
)]
public
DateTime EndDate {
get
;
set
; }
[DisplayOptions(Header =
"Title"
)]
public
string
Title {
get
;
set
; }
[DisplayOptions(Header =
"Detail"
)]
public
string
Detail {
get
;
set
; }
[DisplayOptions(Header =
"Is All Day"
)]
public
bool
IsAllDay {
get
;
set
; }
[Ignore]
public
Color Color {
get
;
set
; }
}
}
Note that is doesn't cover all your potential scenarios. You would also want to take care of when the user selects an existing appointment and possibly load that into the DataForm to be edited. In this case, take a look at the
Calendar's AppointmentTapped event, you would then set the DataForm.source using the selected appointment.
Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items