How to retrieve appointments in UWP from a Windows 10 calendar using C#

别来无恙 提交于 2019-12-02 04:08:42

You can retrieve all the calendar appointments using the Windows.ApplicationModel.Appointments.AppointmentStore class.

In this example I am going to retrieve the appointments in the next 24 hours

AppointmentStore appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

var dateToShow = DateTime.Now.AddDays(0);
var duration = TimeSpan.FromHours(24);

var appCalendars = await appointmentStore.FindAppointmentsAsync(dateToShow, duration);
foreach (var calendar in appCalendars)
{
[...]
}

Remember to grant access to Apointments Capabilities in the package.appxmanifest

According to MSDN:

Through the Windows.ApplicationModel.Appointments namespace, you can create and manage appointments in a user's calendar app.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!