Click to See Complete Forum and Search --> : WPF binding to XML file question


purpleflash
December 15th, 2007, 12:50 PM
I'm using this code:

public Window1()
{
InitializeComponent();

// container listbox
DataSet dsContainers = new DataSet();
dsContainers.ReadXml("c:\\program files\\msts\\users.xml", XmlReadMode.InferSchema);
listBox1.DataContext = dsContainers.Table["container"];


to bind an XML file to a listbox in a WPF form.

Seems to work except that the text shown in the list is:
"System.Data.DataRowView"
"System.Data.DataRowView"
"System.Data.DataRowView"
"System.Data.DataRowView"



kinda like it's showing a text string representing the object type.

How can I get it to display the actual data?

In Windows Forms I would use this:

listBox1.DataSource = dsContainers.Tables["container"];
listBox1.DisplayMember = "publicname";
listBox1.ValueMember = "publicname";

to tell the listbox what field to display, but I can't see how to accomplish this in WPF.