CarCollection cars = null;
string path = @"F:\CustomDictionary.xml";
XmlSerializer serializer = new XmlSerializer(typeof(CarCollection));
StreamReader reader = new StreamReader(path);
cars = (CarCollection)serializer.Deserialize(reader);
List<CarCollection> TrackCollection = new List<CarCollection>();
TrackCollection.Add(cars);
// model is the currently queried object, we return true or false according to the amount of children we have in our MyClasses List
treeListView1.CanExpandGetter = model => ((CarCollection)model).
Car.Count() > 0;
// We return the list of MyClasses that shall be considered Children.
treeListView1.ChildrenGetter = delegate(object x) { return ((CarCollection)x).Car; };
treeListView1.SetObjects(TrackCollection);
[Serializable()]
public class Car
{
[System.Xml.Serialization.XmlElement("StockNumber")]
public string StockNumber { get; set; }
[System.Xml.Serialization.XmlElement("Make")]
public string Make { get; set; }
[System.Xml.Serialization.XmlElement("Model")]
public string Model { get; set; }
}
[Serializable()]
[System.Xml.Serialization.XmlRoot("CarCollection")]
public class CarCollection
{
[XmlArray("Cars")]
[XmlArrayItem("Car", typeof(Car))]
public Car[] Car { get; set; }
}
I want to bind xml file to Treelistview for that written above code after run its showing exception
'Model' is not parameterlessmethod field or property of 'ObjectlistViewDemo.CarcCllection'
referring below Xml file referring below Xml file referring below Xml file referring below Xml file
<?xml version="1.0" encoding="utf-8"?>
<CarCollection>
<Cars>
<Car>
<StockNumber>1020</StockNumber>
<Make>Nissan</Make>
<Model>Sentra</Model>
</Car>
<Car>
<StockNumber>1010</StockNumber>
<Make>Toyota</Make>
<Model>Corolla</Model>
</Car>
<Car>
<StockNumber>1111</StockNumber>
<Make>Honda</Make>
<Model>Accord</Model>
</Car>
</Cars>
</CarCollection>