Back to Devexpress

SchedulerControl.InitNewAppointment Event

wpf-devexpress-dot-xpf-dot-scheduling-dot-schedulercontrol-8cc519e3.md

latest6.6 KB
Original Source

SchedulerControl.InitNewAppointment Event

Occurs before a new AppointmentItem is created in the SchedulerControl.

Namespace : DevExpress.Xpf.Scheduling

Assembly : DevExpress.Xpf.Scheduling.v25.2.dll

NuGet Package : DevExpress.Wpf.Scheduling

Declaration

csharp
public event AppointmentItemEventHandler InitNewAppointment
vb
Public Event InitNewAppointment As AppointmentItemEventHandler

Event Data

The InitNewAppointment event's data class is AppointmentItemEventArgs. The following properties provide information specific to this event:

PropertyDescription
AppointmentGets the appointment for which the element is raised.

Remarks

Handle the InitNewAppointment event to change the default AppointmentItem properties every time the appointment is created by an end-user.

The following code implements a special EventToCommand behavior that allows you to bind an SchedulerControl.InitNewAppointment event to a Delegate Command. The delegate command is generated automatically from a public InitNewAppointment method declared in a POCO View Model view model. Instead of passing event arguments to a method in a view model, the code specifies the NewAppointmentInitConverter converter that processes event arguments.

View Example

xaml
<dxmvvm:Interaction.Behaviors>
    <dxmvvm:EventToCommand EventName="InitNewAppointment" Command="{Binding InitNewAppointmentCommand}">
        <dxmvvm:EventToCommand.EventArgsConverter>
            <local:NewAppointmentInitConverter/>
        </dxmvvm:EventToCommand.EventArgsConverter>
    </dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>

The NewAppointmentInitConverter converter changes the appointment’s label and removes the default reminder.

View Example

csharp
using DevExpress.Mvvm.UI;
using DevExpress.Xpf.Scheduling;

namespace CustomMvvmFormWithRecurrenceExample {
    public class NewAppointmentInitConverter : EventArgsConverterBase<AppointmentItemEventArgs> {
        protected override object Convert(object sender, AppointmentItemEventArgs args) {
            args.Appointment.LabelId = 1;
            args.Appointment.Reminders.Clear();
            return args;
        }
    }
}
vb
Imports DevExpress.Mvvm.UI
Imports DevExpress.Xpf.Scheduling

Namespace CustomMvvmFormWithRecurrenceExample
    Public Class NewAppointmentInitConverter
        Inherits EventArgsConverterBase(Of AppointmentItemEventArgs)

        Protected Overrides Function Convert(ByVal sender As Object, ByVal args As AppointmentItemEventArgs) As Object
            args.Appointment.LabelId = 1
            args.Appointment.Reminders.Clear()
            Return args
        End Function
    End Class
End Namespace

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the InitNewAppointment event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-scheduler-create-reminders-in-code-and-implement-custom-reminder-window/CS/CustomReminderExample/MainWindow.xaml#L23

xml
</StackPanel>
<dxsch:SchedulerControl x:Name="scheduler" Grid.Row="1" InitNewAppointment="Scheduler_InitNewAppointment" RemindersWindowShowing="Scheduler_RemindersWindowShowing">
    <dxsch:SchedulerControl.DataSource>

wpf-scheduler-create-reminders-in-code-and-implement-custom-reminder-window/CS/CustomReminderExample/obj/Debug/net8.0-windows/MainWindow.g.cs#L98

csharp
#line 23 "..\..\..\MainWindow.xaml"
this.scheduler.InitNewAppointment += new DevExpress.Xpf.Scheduling.AppointmentItemEventHandler(this.Scheduler_InitNewAppointment);

wpf-scheduler-create-reminders-in-code-and-implement-custom-reminder-window/VB/CustomReminderExample/obj.NetFX/Debug/MainWindow.g.vb#L97

vb
#ExternalSource("..\..\MainWindow.xaml",23)
AddHandler Me.scheduler.InitNewAppointment, New DevExpress.Xpf.Scheduling.AppointmentItemEventHandler(AddressOf Me.Scheduler_InitNewAppointment)

See Also

How to: Set Default Values for a New Appointment

SchedulerControl Class

SchedulerControl Members

DevExpress.Xpf.Scheduling Namespace