如何使用 C# 从 Windows 10 日历中检索 UWP 中的约会
How to retrieve appointments in UWP from a Windows 10 calendar using C#
我正在使用 C# 在 windows 10 中创建通用 Windows 应用程序,它管理 Windows 日历应用程序中的约会。我可以添加约会,并可以使用 ID 编辑或删除它们。但是,如果不检索它们并进行过滤,我将不知道它们的 ID。
有没有人有使用 C# 在 Windows 10 中检索日历约会列表的经验?
根据MSDN:
Through the Windows.ApplicationModel.Appointments namespace, you can create and manage appointments in a user's calendar app.
您可以使用 Windows.ApplicationModel.Appointments.AppointmentStore class.
检索所有日历约会
在此示例中,我将在接下来的 24 小时内检索约会
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
中授予对 Apointments Capabilities 的访问权限
我正在使用 C# 在 windows 10 中创建通用 Windows 应用程序,它管理 Windows 日历应用程序中的约会。我可以添加约会,并可以使用 ID 编辑或删除它们。但是,如果不检索它们并进行过滤,我将不知道它们的 ID。
有没有人有使用 C# 在 Windows 10 中检索日历约会列表的经验?
根据MSDN:
Through the Windows.ApplicationModel.Appointments namespace, you can create and manage appointments in a user's calendar app.
您可以使用 Windows.ApplicationModel.Appointments.AppointmentStore class.
检索所有日历约会在此示例中,我将在接下来的 24 小时内检索约会
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
中授予对 Apointments Capabilities 的访问权限