How to create business appointment objects with custom fields in .NET MAUI Scheduler (SfScheduler)?
In the .NET MAUI Scheduler, you can represent business appointments by adding an object collection as the AppointmentsSource. This is achieved by utilizing the AppointmentMapping class, which allows you to map the custom fields of your business object to the scheduler.
STEP 1:
Define a business object class with the required fields to represent details of appointments.
public class FlightDetails
{
public string AirlinesName { get; set; }
public DateTime DepartureTime { get; set; }
public DateTime ArrivalTime { get; set; }
public string Price { get; set; }
public TimeZoneInfo DepartureTimeZone { get; set; }
public TimeZoneInfo ArrivalTimeZone { get; set; }
public Brush AirlinesColor { get; set; }
}
STEP 2:
Use the AppointmentMapping to map the properties in the business object class to the scheduler's required appointment fields.
<scheduler:SfScheduler x:Name="Scheduler" View="Month"> <scheduler:SfScheduler.AppointmentMapping> <scheduler:SchedulerAppointmentMapping Subject="AirlinesName" StartTime="DepartureTime" EndTime="ArrivalTime" Notes="Price" Background="AirlinesColor" StartTimeZone="DepartureTimeZone" EndTimeZone="ArrivalTimeZone"/> </scheduler:SfScheduler.AppointmentMapping> </scheduler:SfScheduler>
STEP 3:
Create a business appointment object and assign them to the AppointmentSource property.
public MainPage()
{
InitializeComponent();
FlightDetails flightDetails = new FlightDetails();
flightDetails.AirlinesName = "Air - 1";
flightDetails.DepartureTime = DateTime.Today.Date.AddHours(9);
flightDetails.ArrivalTime = flightDetails.DepartureTime.AddHours(6);
flightDetails.AirlinesColor = Brush.Green;
flightDetails.Price = "$ 4000";
flightDetails.DepartureTimeZone = TimeZoneInfo.Utc;
flightDetails.ArrivalTimeZone = TimeZoneInfo.Utc;
var flightsDetails = new ObservableCollection<FlightDetails>();
flightsDetails.Add(flightDetails);
this.Scheduler.AppointmentsSource = flightsDetails;
}
Output
|
Conclusion
I hope you enjoyed learning how to create business appointment objects with custom fields in .NET MAUI Scheduler.
Refer to our .NET MAUI Scheduler feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI Scheduler documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Scheduler and other .NET MAUI components.
Please let us know in the following comments section if you have any queries or require clarifications. Contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
