gpt4 book ai didi

c# - 如何从 Windows Phone 8.1(不是 Silverlight)联系人获取生日

转载 作者:太空宇宙 更新时间:2023-11-03 13:12:58 25 4
gpt4 key购买 nike

我正在尝试用我所有电话联系人的生日填充一个 ListView ,但不幸的是,这似乎比我最初想象的要难 - 或者我遗漏了一些重要的东西......

关于 Windows Phone 8.1 Silverlight,它似乎是 easy因为有一个 Birthday 属性。但是如何在 Windows Phone 8.1 Runtime 中获取联系人的生日呢?

为什么没有属性?原来如此简单……

var contactStore = await ContactManager.RequestStoreAsync();
var contacts = await contactStore.FindContactsAsync();

foreach (var contact in contacts)
{
// var birthday = contact.Birthday; // unfortunately not possible
}

最佳答案

This link这里终于为我指明了正确的方向:

var contactStore = await ContactManager.RequestStoreAsync();
var contacts = await contactStore.FindContactsAsync();

foreach (var contact in contacts)
{
// var list = contact.ImportantDates;
// Enumerating this list we can check for ContactDateKind == Birthday
// Or even shorter:

var birthday = contact.ImportantDates.FirstOrDefault(d => d.Kind == ContactDateKind.Birthday);

// birthday is null if there is no birthday saved for the current contact
}

关于c# - 如何从 Windows Phone 8.1(不是 Silverlight)联系人获取生日,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27678800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com