Reputation: 1646
I'm unable to bind a XamDataGrid
to an XmlDataProvider
property in my MVVM styled project.
I'm getting an XML string from a WebService call, creating an XmlDataProvider and then trying to bind it to the XamDataGrid. The XmlDataProvider is getting initialized properly. It's just the binding part that's not going right.
<igDP:XamDataGrid DataSource="{Binding Source=provider, XPath=Row, Mode=OneWay}" />
public XmlDataProvider provider { get; private set; }
private void method()
{
string xmlString = webservice.runQuery();
// prepare xml
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlString);
provider = new XmlDataProvider();
if (provider != null)
{
provider.Document = doc;
provider.XPath = "/Results";
}
}
<Results>
<Row>
<! -- my data -->
</Row>
<Row>
<! -- my data -->
</Row>
</Results>
I was able to do this without much difficulty in the code-behind way by following the sample Infragistics code. But, it's the MVVM way I'm having difficulty with.
This solution doesn't seem to work for XamDataGrid.
Upvotes: 0
Views: 1018
Reputation: 1646
This worked:
<igDP:XamDataGrid DataContext="{Binding provider}" DataSource="{Binding XPath=Row, Mode=OneWay}" />
Also, I was originally missing the following:
private set
{
_provider = value;
OnPropertyChanged("provider");
}
Upvotes: 1