2011-10-18 46 views
0

我的WP7应用程序包括: 登录页面:我在其中插入一个用户名和密码,点击一个按钮发送XML请求,我得到我需要一个XML文件我必须将它存储在某处的user_id可以使用它。 朋友页:发送包含user_ID的请求,我得到的一个XML文件中的朋友,我要分析显示列表清单,但我有,因为一旦用户选择列表中的朋友来存储friend_id过它将导航到显示此朋友中的信息的另一个页面,并使用包含friend_id的url。 问题是,在登录页面中,我使用querystring方法重新使用user_id,它工作,但int友人页面没有工作,我没有找到一个简单的方法来存储我的朋友信息和重用他们又特别是因为下面的XML解析:存储数据,并用它在WP7

void friends_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) 
    { 
     if (e.Error == null) 
     { 
      var doc = XDocument.Load(new StringReader(e.Result)); 
      var items = from item in doc.Element("information").Elements("item") 
         select new User 
         { 
          id = item.Element("id").Value, 
          nom = item.Element("nom").Value, 
          photo = item.Element("photo").Value 
         }; 
      listBoxFriends.ItemsSource = items; 
     } 
    } 

回答

0

如果您正在寻找保存ID的方法。你可以用它持续的应用

IsolatedStorageSettings userSettings = IsolatedStorageSettings.ApplicationSettings; 
List<int> friendidList = new List<int>(); 
userSettings.Add("friend_ids", friendidList); 
userSettings.Save(); 

得到的值回

object friendids; 
userSettings.TryGetValue("friend_ids", out friendids); 
0
You can use PhoneApplictaionStates/ Isolated Storage for storing the data. 
for eg :- 
you can save the username to state like this 
PhoneApplicationService.Current.State[key] = userName.Text; // here key is the identifier 
for retrieving the username 
string userName = PhoneApplicationService.Current.State[key]; 
+0

能否请您进一步解释这种方法的IsolatedStorage) – MarTech

+0

HTTP://www.kunal-chowdhury的.com/2011/06 /窗口电话-7-芒果教程-8- what.html –

相关问题