Articles in this section

How to add additional attributes to appointments WinUI Scheduler?

In the WinUI Scheduler, add additional attributes for the appointments. In this section, an additional attribute (Appointment ID) is added to an appointment. Get the tapped appointment details when tapping the cell of the Scheduler using the CellTapped event in WinUI.

XAML

Handler for CellTapped is defined with the Scheduler .

<Grid>
    <Grid.DataContext>
        <local:SchedulerViewModel/>
    </Grid.DataContext>
 
    <scheduler:SfScheduler x:Name="Schedule" ItemsSource="{Binding AppointmentCollection}" ViewType="Week" CellTapped="OnCellTapped"/>
</Grid>

C#

Create a separate class which inherits from the ScheduleAppointment, and include required properties in this class for adding additional attribute to the appointment.

public class CustomAppointment : ScheduleAppointment, INotifyPropertyChanged
{
    private string appointment_ID;
    public string AppointmentID
    {
        get { return appointment_ID; }
        set
        {
            appointment_ID = value;
            OnPropertyChanged("AppointmentID");
        }
    }
    public event PropertyChangedEventHandler PropertyChanged;
    private void OnPropertyChanged(string propertyName)
    {
        var eventHandler = this.PropertyChanged;
        if (eventHandler != null)
            eventHandler(this, new PropertyChangedEventArgs(propertyName));
    }
}

C#

Schedule a meeting for a day by setting StartTime, EndTime, AppointmentID, AppointmentBackground, and Subject class. Create appointments of type ObservableCollection <CustomAppointment> and assign those appointment collections to the ItemsSource property.

 

public class SchedulerViewModel
{
    public ObservableCollection<CustomAppointment> AppointmentCollection
    {
        get;
        set;
    }
    CustomAppointment scheduleAppointment;
    public SchedulerViewModel()
    {
        scheduleAppointment = new CustomAppointment();
        scheduleAppointment.Subject = "Meeting";
        scheduleAppointment.AppointmentID = "579";
        scheduleAppointment.AppointmentBackground = Brushes.Green;
        scheduleAppointment.StartTime = DateTime.Now.Date.AddHours(10);
        scheduleAppointment.EndTime = DateTime.Now.Date.AddHours(12);
        AppointmentCollection = new ObservableCollection<CustomAppointment>();
        AppointmentCollection.Add(scheduleAppointment);
    }
}

C#

In the CellTapped, get the tapped appointment ID details by the property of the Appointment of CellTappedEventArgs.

//Event Customization
private async void OnCellTapped(object sender, CellTappedEventArgs e)
{
    var appointment = e.Appointment as CustomAppointment;
    if (appointment != null && appointment.Subject == "Meeting")
    {
        var dateTime = e.DateTime.ToString(); 
        ContentDialog contentDialog = new ContentDialog() 
        {
            Title = "Selected Appointment ID ",
            Content = " " + " " + appointment.AppointmentID.ToString(),
            CloseButtonText = "Ok" 
        };
        //Set XamlRoot for WinUI desktop applications
        contentDialog.XamlRoot = this.Schedule.XamlRoot;
        await contentDialog.ShowAsync();
    }
}

Focus

Take a moment to pursue the documentation. You can find options like types of appointments, customizing the appearance of appointments, etc.



Conclusion

I hope you enjoyed learning about how to add additional attributes to appointments WinUI Scheduler (Calendar).
You can refer to our WinUI Scheduler feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinUI Scheduler example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied