Search code examples
wpfxsdteleriktreeviewinfragistics

WPF Bind XSD Schema to TreeView


The Table names of My DataSet will act as nodes of my tree view. I want to bind XSD schema to the treeView the code I have tired is : System.IO.StreamReader xmlStream = new System.IO.StreamReader(@"C:\code\depot\profile.xsd"); DataSet dataSet = new DataSet(); dataSet.ReadXmlSchema(xmlStream); xmlStream.Close(); return dataSet.Tables[0]; and grid.ItemsSource = ViewModel.GetDataFromXML(); XAML

I can even use telerik/infragistics where ever it works.

Note: I would like to mention It is schema which will be shown in treeView and XSD doesnot contain any data.


Solution

  • You can try this:

     System.IO.StreamReader xmlStream = new System.IO.StreamReader(@"C:\NORTHWNDDataSet.xsd");
     DataSet dataSet = new DataSet();
     dataSet.ReadXmlSchema(xmlStream);
     xmlStream.Close();
    
     treeView.ItemsSource = dataSet.Tables;
     reeView.DisplayMemberPath = "TableName";