XML : Cast var as an itemsource for a longlistviewer

I have a variable named items that finds a set of descendants of an xml element and binds them to a textblock on a longlistviewer in Windows Phone 8.1 Silverlight. When I go and try to set the ItemsSource with this variable, it comes up with an error:

Cannot implicitly convert type System.Collections.Generic.IEnumerable<Lists.ListsXmlBinder> to System.Collections.IList. An explicit conversion exists (are you missing a cast?)

Here is my code:

  using (var storage = IsolatedStorageFile.GetUserStoreForApplication())  {      using (Stream stream = storage.CreateFile("list.xml"))      {          XDocument document = XDocument.Load(stream);          document.Element("lists").Add(new XElement("list", new XElement("name", "random list"), new XElement("date", DateTime.Now.ToString())));          document.Save(stream);            var items = from query in document.Descendants("list")                      select new ListsXmlBinder                      {                          Name = query.Element("name").Value,                          Date = query.Element("date").Value                      };            lists_ListViewer.ItemsSource =  items;      }  }    

Anyway to solve this problem?

No comments:

Post a Comment