Could someone help me out, to why my listbox is empty?
The XmlDocument contains the following XML:
<Config>
<Tabs>
<Tab Name="Test1" />
<Tab Name="Test2" />
</Tabs>
</Config>
In my XAML file I have tried the following
<Window>
<Grid>
<ListBox DataContext="{Binding {StaticResource Data}, XPath=//Tabs}" ItemsSource="{Binding XPath=Tab/@Name}">
</ListBox>
</Grid>
<Window>
I know I haven't set up the binding to name attribute but shouldn't this display XmlDocument.XmlNode.ToString() for each Tab Node if it was working?
My C# Constructor Code behind:
InitializeComponent();
this.doc = new XmlDocument();
doc.LoadXml(config.document.OuterXml);
XmlDataProvider provider = (XmlDataProvider)Resources["Data"];
provider.Document = doc;
provider.Refresh();
With config.document.OuterXml
being a valid document containing the above xml.
I got this working with procedural code using Collections, but I have been trying to figure out how to bind directly to XML.
Update: ListBox empty
Now there is no binding errors, but my listbox is coming up empty, I have double checked my XML file, and even did MessageBox.Show(provider.Document.OuterXML) and can confirm that the XmlDocument does have the correct nodes.
Thanks in advance