2010-11-22 45 views
1

我花了幾個小時尋找如何做到這一點,不幸的是作爲一個C#新手不能解決如何做到這一點,雖然我確信它很簡單。我試圖抓取我存儲在XML中的數據並將其綁定到列表。我當前使用的是foreach方法,只是使用代碼將項目添加到列表框中,但是當您想要像我一樣存儲時,這看起來效率低下並且有點笨拙。我正在使用以下代碼從當前的IO中檢索項目:用XML綁定數據linq

using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) 
      { 
       foreach (string items in storage.GetFileNames("*.item")) 
       { 
         XElement _xml; 

         IsolatedStorageFileStream location = new IsolatedStorageFileStream(items, System.IO.FileMode.Open, storage); 

         System.IO.StreamReader file = new System.IO.StreamReader(location); 
         _xml = XElement.Parse(file.ReadToEnd()); 
         XAttribute att = _xml.Attribute("att"); 

在此先感謝!

回答