After following the previous topic, you should be able to use MindFusion.Scheduling classes in your project.
Initialize the library
Call the UseMindFusionScheduling extension from CreateMauiApp to configure the library:
C#
Copy Code
|
---|
using MindFusion.Scheduling;
namespace CalendarMauiApp;
public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp<App>() .UseMindFusionScheduling() ........................);
return builder.Build(); } } |
Add a Calendar to Xaml UI
- Add an xmlns attribute to the root Xaml object and set its value to http://mindfusion.eu/scheduling/maui, which lets you create objects from the Scheduling namespace in Xaml.
- Add a Calendar element, and set its Name attribute to a variable name that lets you access the instance from code-behind:
Xaml
Copy Code
|
---|
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:ms="http://mindfusion.eu/scheduling/maui" x:Class="MinApp.MainPage">
<Grid>
<ms:Calendar x:Name="calendar" />
</Grid>
</ContentPage> |
Create appointments
You can create appointments programmatically by instantiating the Appointment class and adding the objects to Items collection:
C#
Copy Code
|
---|
public MainPage() { InitializeComponent();
calendar.Date = DateTime.Today;
var app1 = new Appointment(); app1.StartTime = calendar.Date.AddDays(0); app1.EndTime = app1.StartTime + TimeSpan.FromHours(24); app1.HeaderText = "Hello"; calendar.Schedule.Items.Add(app1);
var app2 = new Appointment(); app2.StartTime = calendar.Date.AddDays(1); app2.EndTime = app2.StartTime + TimeSpan.FromHours(24); app2.HeaderText = "World!"; calendar.Schedule.Items.Add(app2); } |
Calendar interaction
Set the DragBehavior property to specify whether user's touch / mouse input draws new appointments, selects date cells, or scrolls the view. If AllowContextMenu is enabled, users can use a hold gesture to display a context menu with commands to edit or delete appointments.
Browse the Programming Interface Overview section of this help file to learn more about the functionality provided by the MindFusion.Scheduling classes, methods and properties.