Quantcast
Viewing all articles
Browse latest Browse all 18858

ListBox is not populated with an XMl binding with a file

Hi All,

I have just started WPF on .Net3.5.

I am facing a concern while populating ListBox from an xml file. Actually this xml file has been generated with someobject.WriteXml operation on a local data object. It looks like this:

<?xml version="1.0" standalone="yes"?><NewDataSet><xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="AnniversaryDetails"><xs:complexType><xs:sequence><xs:element name="Event_Id" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="1" type="xs:int" minOccurs="0" /><xs:element name="Event_Name" type="xs:string" minOccurs="0" /><xs:element name="Event_Type" type="xs:string" minOccurs="0" /><xs:element name="Event_DateTime" type="xs:dateTime" minOccurs="0" /><xs:element name="Event_PicUrl" type="xs:string" minOccurs="0" /><xs:element name="Event_IsAlarmReq" type="xs:boolean" minOccurs="0" /></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><AnniversaryDetails><Event_Id>1</Event_Id><Event_Name>Test Event</Event_Name><Event_Type>Others</Event_Type><Event_DateTime>2013-03-31T12:22:06.5200419+05:30</Event_DateTime><Event_PicUrl /><Event_IsAlarmReq>false</Event_IsAlarmReq></AnniversaryDetails></NewDataSet>

My Xaml file looks like:

 
<Window.Resources><XmlDataProvider x:Key="rk" IsAsynchronous="False" IsInitialLoadEnabled="True"/></Window.Resources>    <ListBox Name="listViewRecords" Grid.Column="0" DataContext="{Binding {StaticResource rk}, XPath=NewDataSet/AnniversaryDetails}"  />

The XAML.cs file has following COnstructor:

        public MyManager()
        {
            InitializeComponent();
            XmlDocument d = new XmlDocument();
            d.Load(@"d:\rohit\test\data.xml");          
            ((XmlDataProvider)Resources["rk"]).Document = d;
        }

I want the Event_Name should be displayed in the listbox.  Please help..

Thanks

Regards

Rohit


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>