簡體   English   中英

WP8 KnownContactProperties.Birthdate無法設置值

[英]WP8 KnownContactProperties.Birthdate can not set value

var store = await ContactStore.CreateOrOpenAsync();
StoredContact sc = new StoredContact(store);
IDictionary<string, object> values = await sc.GetPropertiesAsync();
values[KnownContactProperties.FamilyName] =  "bbb";
values[KnownContactProperties.GivenName]=  "worerrrrld";

//*************problem here**************
Nullable<DateTime> birth = DateTime.Now;
values[KnownContactProperties.Birthdate] = birth;
//values[KnownContactProperties.Birthdate] = DateTime.Now;
//values[KnownContactProperties.Birthdate] = "2010-05-10";
//it will cause exception by any way above.
//***************************************

await sc.SaveAsync();//Exception throw here  :System.InvalidCastException

關於Windows Phone8 API

Windows.Phone.PersonalInformation命名空間

關於Class StoredContact太奇怪了!

有誰能夠幫助我! 如何設置此KnownContactProperties.Birthdate

InvalidCastException是正常的,因為期望的對象是DateTimeOffset。

嘗試這個:

values[KnownContactProperties.Birthdate] = new DateTimeOffset(DateTime.Parse("2010-05-10"));

問候。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM