c# - 如何使用 C# 从 Windows 10 日历中检索 UWP 中的约会

标签 c# list calendar win-universal-app appointment

我正在使用 C# 在 Windows 10 中创建通用 Windows 应用程序,它管理 Windows 日历应用程序中的约会。我可以添加约会,并可以使用 ID 编辑或删除它们。但是,如果不检索它们并进行过滤,我将不知道它们的 ID。

有人有过使用 C# 在 Windows 10 中检索日历约会列表的经验吗?

最佳答案

您可以使用 Windows.ApplicationModel.Appointments.AppointmentStore 类检索所有日历约会。

在这个例子中,我将在接下来的 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# - 如何使用 C# 从 Windows 10 日历中检索 UWP 中的约会,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37160774/

相关文章:

c# - 是否可以从 .net core 查询表存储?

c# - ElasticProperty - 索引在 Nest 中不起作用 - ElasticSearch

c# - 在不同平台(64 位)上执行线程

python - 使用索引手动切片列表,Python

android - 如何突出显示日历日期哪些日期来自数据库

php - 当变量为空时使用 IN_ARRAY 获取错误

c# - 用最小起订量测试这个的正确方法

c# - 检查 List<> 中的重复项

java - af :Calendar component, 按列类型过滤

python - 在 Python 中将具有 1 个变量的列表转换为 float