Articles in this section

How to get the current month appointments in the WPF Scheduler (Calendar)

In the WPF SfScheduler, get and show the current month appointments in the Alert window using the Appointment Collection from the ViewModel in the ViewChanged event.

C#

Using the ViewChanged event of the WPF Scheduler, get the current month appointments using the Appointment Collection property from the ViewModel.

public class ScheduleBehavior : Behavior<Grid>
{
    private void OnVisibleAppointmentsClicked(object sender, System.Windows.RoutedEventArgs e)
    {
        if (appointmentCollection.Count > 0)
        {
            StringBuilder message = new StringBuilder();
            for (int i = 0; i < appointmentCollection.Count; i++)
            {
                message.AppendLine(appointmentCollection[i].Subject.ToString());
            }
            MessageBox.Show("This month contains " + appointmentCollection.Count + " appointments\n\n" + message.ToString());
        }
        else
        {
            MessageBox.Show("No appointments", "Appointment Details", MessageBoxButton.OK);
        }
    }
 
    private void OnSchedulerViewChanged(object sender, ViewChangedEventArgs e)
    {
        GetVisibleAppointment(e.NewValue.ActualStartDate);
    }
 
    private ScheduleAppointmentCollection GetVisibleAppointment(DateTime startDate)
    {
        appointmentCollection = new ScheduleAppointmentCollection();
        var app = (this.schedule.DataContext as SchedulerViewModel).Appointments;
        foreach (var appointment in app)
        {
            if (appointment.StartTime.Month == startDate.Month)
            {
                appointmentCollection.Add(appointment);
            }
        }
        return appointmentCollection;
    }
}

XAML

Bind the appointments to a schedule using the Scheduler.ItemsSource property.

<Window.DataContext>
    <local:SchedulerViewModel/>
</Window.DataContext>
 
<Grid x:Name="grid">
     …….. 
    <syncfusion:SfScheduler x:Name="schedule" ItemsSource="{Binding Appointments}" ViewType="Month" Grid.Row="2">
        <syncfusion:SfScheduler.MonthViewSettings>
            <syncfusion:MonthViewSettings AppointmentDisplayMode="Indicator"/>
        </syncfusion:SfScheduler.MonthViewSettings>
 
    </syncfusion:SfScheduler>
    <interactivity:Interaction.Behaviors>
        <local:ScheduleBehavior/>
    </interactivity:Interaction.Behaviors>
</Grid>

View sample in GitHub

SfScheduler current month appointment

 

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