I have a variable named
items
TextBlock
LongListViewer
ItemSource
Cannot implicitly convert type
toSystem.Collections.Generic.IEnumerable<Lists.ListsXmlBinder>
. An explicit conversion exists (are youSystem.Collections.IList
missing a cast?)
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;
}
}
Just add a call to ToList() to convert the IEnumerable
to a list:
var items = (from query in document.Descendants("list")
select new ListsXmlBinder
{
Name = query.Element("name").Value,
Date = query.Element("date").Value
}).ToList();