Back to Devexpress

Get Started with DevExpress Scheduler for .NET MAUI

maui-403994-scheduler-and-calendar-scheduler-get-started.md

latest4.6 KB
Original Source

Get Started with DevExpress Scheduler for .NET MAUI

  • Nov 25, 2024
  • 4 minutes to read

The DevExpress Mobile UI for .NET MAUI suite contains a set of the following views to display and manage appointments (scheduled events): DayView, WorkWeekView, WeekView, and MonthView.

This tutorial explains how to create a WorkWeekView instance and bind it with a data source that stores appointments.

View Example: Get Started with DevExpress Scheduler for .NET MAUI

Prerequisites

Refer to the following pages before you proceed with this Getting Started lesson:

Create a New Application and Place a Scheduler on the Main Page

  1. Create a new .NET MAUI cross-platform solution (for example, Scheduler_GettingStarted) and install the DevExpress.Maui.Scheduler NuGet Package. See the following topic for more information: Register DevExpress NuGet Gallery to Access Mobile UI for .NET MAUI.

  2. In the MauiProgram.cs file, call the the following UseDevExpress * methods to register handlers for the DevExpress Scheduler Control:

  3. In the MainPage.xaml file, declare the dx XAML namespace and add a WorkWeekView to a content page:

Prepare a Model and View Model

  1. Add the following classes that represent data objects in the application:

  2. Declare the ReceptionDeskViewModel class that contains appointments for the scheduler.

Bind the Scheduler to the View Model

In the MainPage.xaml file:

  1. Assign a ReceptionDeskViewModel object to the content page’s BindingContext property.
  2. Set the WorkWeekView.DataStorage property to a SchedulerDataStorage object and use the SchedulerDataStorage.DataSource property to bind the scheduler to a source of appointments.
  3. Set the DataSource.AppointmentsSource property to the collection of appointment objects.
  4. Use the DataSource.AppointmentMappings property to map appointment properties to the MedicalAppointment class properties.
xaml
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Scheduler_GettingStarted"
             xmlns:dx="http://schemas.devexpress.com/maui"
             x:Class="Scheduler_GettingStarted.MainPage">
    <ContentPage.BindingContext>
        <local:ReceptionDeskViewModel/>
    </ContentPage.BindingContext>
    <dx:WorkWeekView>
        <dx:WorkWeekView.DataStorage>
            <dx:SchedulerDataStorage>
                <dx:SchedulerDataStorage.DataSource>
                    <dx:DataSource AppointmentsSource="{Binding MedicalAppointments}">
                        <dx:DataSource.AppointmentMappings>
                            <dx:AppointmentMappings 
                            Id="Id" 
                            Start="StartTime" 
                            End="EndTime" 
                            Subject="Subject"
                            LabelId="LabelId"
                            Location="Location"/>
                        </dx:DataSource.AppointmentMappings>
                    </dx:DataSource>
                </dx:SchedulerDataStorage.DataSource>
            </dx:SchedulerDataStorage>
        </dx:WorkWeekView.DataStorage>
    </dx:WorkWeekView>
</ContentPage>

Note

The Scheduler allows you to delete only one item at a time.