【发布时间】:2014-11-05 12:31:01
【问题描述】:
我想从 xml 文件向联系人列表中添加多个联系人,但 saveContactTask.Show(); 在联系人列表中添加了一位联系人,请任何人告诉我如何解决此问题。
这是我的代码:
private void AddContacts(object sender, RoutedEventArgs e) {
using (IsolatedStorageFile istf = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream istfs = istf.OpenFile("MyContacts.xml",FileMode.Open))
{
XDocument doc = XDocument.Load(istfs);
var query = from d in doc.Root.Descendants("Contacts")
select new
{
firstName = d.Element("name").Value,
mobilePhone = d.Element("phone").Value
};
foreach (var po in query)
{
saveContactTask.FirstName = po.firstName;
saveContactTask.MobilePhone = po.mobilePhone;
saveContactTask.Show();
}
}
}
【问题讨论】:
-
我认为这个链接可以帮助你 [stackoverflow.com/questions/18426871/… [1]: stackoverflow.com/questions/18426871/…
标签: windows-phone-8