如何使用C#从Windows 10日历中检索UWP中的约会 [英] How to retrieve appointments in UWP from a Windows 10 calendar using C#
问题描述
我正在使用C#在Windows 10中创建一个通用Windows应用程序,该应用程序在Windows日历应用程序中管理约会.我可以添加约会,并且可以使用ID来编辑或删除约会.但是,如果不检索它们并进行过滤,我将不知道它们的ID.
I'm creating a Universal Windows Application in windows 10 using C# which manages appointments in the Windows Calendar App. I am able to add appointments, and can edit or delete them using the ID. However, without retrieving them and filtering, I won't know their ID.
有人在使用C#检索Windows 10中的日历约会列表方面有任何经验吗?
Has anybody had any experience with retrieving a list of calendar appointments in Windows 10 using C#?
推荐答案
您可以使用Windows.ApplicationModel.Appointments.AppointmentStore类检索所有日历约会.
You can retrieve all the calendar appointments using the Windows.ApplicationModel.Appointments.AppointmentStore class.
在此示例中,我将在接下来的24小时内检索约会
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)
{
[...]
}
请记住要授予对package.appxmanifest中的约会功能的访问权限
Remember to grant access to Apointments Capabilities in the package.appxmanifest
这篇关于如何使用C#从Windows 10日历中检索UWP中的约会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!