Hi All,
I have XmlDocument which is attached to XmlDataProvider.Document, this XmlDataProvider is bind to XamDataGrid. Now when i update or change some Node's valule of my XmlDocument which is bind to Grid, is not getting refresh on UI.
When i make some scroll down or up then it gets refresh on UI.
Can anybody help out to refresh UI when node value get change??
Thanks in advance..
I wasn't talking about BindingList or ObservableCollection which have change notifications. I was talking about your scrolling refresh issue.
Again, there are lots of posts on this forum about similar things.
Most people conclude that the easiest way of refreshing the data grid is to reset the datacontext/datasource like follows:
grid.DataContext = null;
grid.DataContext = newSource;
Hi,
But seems i didn't get any solution to refresh the Grid which is bound to XmlDocument which uses XmlDataProvider, If you're using BindingList kind of dataprovider it refresh automatically. But my application is Service oriented where Service returning me Result Asynchronously and binding in same manner. So i have to use XmlDataprovider to make Binding Asynchronous.
It will be helpful if u elaborate more what exactly you want to say.
It's not just XmlDataProvider that has the refresh problem. It's anything and everything as far as I'm aware. There are lots of posts on this forum if you do a search for "Refresh" which have various solutions.
I make many hit and trial on refreshing the XamDataGrid which is bound to XmlDocument using XmlDataProvider as dataprovider for grid and come to a solution.
Solution for this:
I have implemented document NodeChanged event.
m_DataProvider.Document.NodeChanged += new XmlNodeChangedEventHandler(Document_NodeChanged);
When i update or change some Node's valule of my XmlDocument which is bound to Grid it triggers Document_NodeChanged Event. For eg. If i change node value on button click as given below.
private void button1_Click(object sender, RoutedEventArgs e) { foreach (XmlElement result in m_DataProvider.Document.SelectNodes("//Result")) { result.SelectSingleNode("TestValue").InnerText = "True"; } }
And in Nodechanged event find the changed DataRecord using changed node, hide DataRecord and show it again as given below.
It will refresh the Grid without changing Grid's Record Selection or its Active selection.
void Document_NodeChanged(object sender, XmlNodeChangedEventArgs e) { // get the record using XamDataGrid's function which will returns the changed Record. DataRecord resultRecord = myXamDataGrid.GetRecordFromDataItem(e.NewParent.ParentNode, true); // to refresh the grid just hide the record and make it visible again. // its shows the updated values. if (resultRecord != null) { resultRecord.Visibility = Visibility.Collapsed; resultRecord.Visibility = Visibility.Visible; } }
If any other way anybody finds related to this problem will be helpful. Any suggestions or advice are welcome.