Hi All i am facing the same problem
can you please help me anybody on this.
I have wcf has returning the xelement with parents,child,subchild elements from that i want to bind to the treeview control as like parent,child ,subchild elements,
Please help me on this
this is wcf has retun as xelement from this i want to do find parent,child,subchild and bind to silverlight4 treeview.
here i am getting object reference not set error.
="1.0"="utf-8"
<Regions>
<Region name="Americas-01">
<SubRegionOne name="LatinAmerica-05">
</SubRegionOne>
<SubRegionTwo name="MCA-60">
</SubRegionTwo>
<SubRegionThree name="CAC-37">
</SubRegionThree>
<Country name="HPEruope-14">
</Country>
</Region>
<Region name="EMEA-02">
<SubRegionOne name="LatinAmerica-05">
</SubRegionOne>
<SubRegionTwo name="MCA-60">
</SubRegionTwo>
<SubRegionThree name="CAC-37">
</SubRegionThree>
<Country name="HPEruope-14"></Country>
</Region>
<Region name="AsiaPacific-03">
<SubRegionOne name="LatinAmerica-05">
</SubRegionOne>
<SubRegionTwo name="MCA-60">
</SubRegionTwo>
<SubRegionThree name="CAC-37">
</SubRegionThree>
<Country name="HPEruope-14"></Country>
</Region>
</Regions>
[DataContract]
public class GeoDataProvider
{
[DataMember]
public string Region { get; set; }
[DataMember]
public string SubRegionOne { get; set; }
[DataMember]
public string SubRegionTwo { get; set; }
[DataMember]
public string SubRegionThree { get; set; }
[DataMember]
public string Country { get; set; }
[DataMember]
public List<GeoDataProvider> GeoSubItems { get; set; }
} XDocument xDocument = XDocument.Load("Mpo_Admin.xml");
GeoDatatSource = this.GetGeoSource(xDocument.Element("Regions"));
GeotreeView.ItemsSource = GeoDatatSource;
private List<GeoDataProvider> GetGeoSource(XElement element)
{
try
{
return (from Regiondata in element.Elements("Region")
select new GeoDataProvider()
{
Region = Regiondata.Attribute("name").Value,
SubRegionOne = Regiondata.Attribute("name").Value,
SubRegionTwo = Regiondata.Attribute("name").Value,
SubRegionThree = Regiondata.Attribute("name").Value,
Country = Regiondata.Attribute("name").Value,
GeoSubItems = this.GetGeoSource(Regiondata)
}).ToList();
}
catch (Exception ex)
{
throw ex;
}
}
Advanced thank you,
Regards,
Narasimha