Data binding with XML linq
I have spent literally hours searching for how to do this and unfortunatly being a C# novice cannot work out how to do this although im sure its pretty simple. I am trying to grab the data I have stored in XML and bind it to a list. I was currently using the foreach method and just adding items to the listbox using the code but this seems inefficient and a bit clumsey when you want to store as much as I do. I'm using the following code to retreive items from IO at current:
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
f开发者_JAVA百科oreach (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");
Thanks in advance!
I posted a sample project demonstrating xml -> linq -> data binding here.
binding a Linq datasource to a listbox
精彩评论