How to retrieve appointments in UWP from a Windows 10 calendar using C#(如何使用 C# 从 Windows 10 日历中检索 UWP 中的约会)
问题描述
我正在使用 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 中授予对 Apointments Capabilities 的访问权限
Remember to grant access to Apointments Capabilities in the package.appxmanifest
这篇关于如何使用 C# 从 Windows 10 日历中检索 UWP 中的约会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 C# 从 Windows 10 日历中检索 UWP 中的约会
基础教程推荐
- 获取C#保存对话框的文件路径 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 将数据集转换为列表 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 如果条件可以为空 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
