I have a simple Linq to XML query that i run and the results are bound to a listbox (via a collection). What i can’t figure out is how to alter the result before binding them, for example. I have the following code:
XElement xmlEvents = XElement.Parse(e.Result);
lstb.ItemsSource = from GetEvents in xmlEvents.Descendants("e2event")
select new GetEvents
{
eventid = GetEvents.Element("eventid").Value,
eventtime = GetEvents.Element("eventtime").Value
};
eventtime returns a linux time stamp, i have a little method that converts this into a datetime stamp. So how would i go about converting to this before binding to the listbox?
Well the simplest approach would be to change your projection:
(Where
ConvertTimeis your method.)Note that if this is an integer value, you could get LINQ to XML to perform the numeric conversion for you: