Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1025
xamDataGrid does not update after xml change
posted

I have the following xmlDataProvider specified. After moving an xmlNode to a different position in it parent node, the datagrid tree does not update..

 XmlDataProvider xdp = new XmlDataProvider();

xdp.Document = doc;

xdp.XPath =
"perform_select_product_structure_result/product_structures";

Binding bd = new Binding();

bd.Mode = BindingMode.TwoWay;

bd.Source = xdp;

bd.XPath =
"product_structure";

theDataGrid.SetBinding(MetrixDataGrid.DataSourceProperty, bd);

private void MoveNodeUp(object sender, RoutedEventArgs e)

{

//MessageBox.Show(e.ToString());

if (theDataGrid.SelectedItems.Records.Count > 0)

{

DataRecord dr = theDataGrid.SelectedItems.Records[0] as DataRecord;if (dr != null)

{

XmlNode row = dr.DataItem as XmlNode;

XmlNode newRow = row.Clone();

XmlNode prev = row.PreviousSibling;

if (prev != null)

{

XmlNode parent = row.ParentNode;

parent.InsertBefore(newRow, prev);

parent.RemoveChild(row);

 

}

}

}