View Single Post
Old 06-22-2009   #3 (permalink)
dave


 
 

RE: wpf xml twoway data binding problem?



"Linda Liu[MSFT]" wrote:
Quote:

> Hi Dave,
>
> When using the TwoWay binding mode, data binding does update the data in
> the XmlDataProvider if the bound TextBox's text is changed. But data
> binding doesn't save the changes back to the local xml file.
>
> To save changes back to the local xml file, you can get the XmlDocument
> object representing the xml file and call the Save method to save the
> changes to the xml file. You can do this work in the TextChanged event
> handler of the TextBox. For example:
>
> private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
> {
> XmlDataProvider provider =
> (XmlDataProvider)this.FindResource("datarootDS");
> provider.Document.Save(@"C:\demo\test.xml");
> }
>
> Hope this helps.
> If you have any question, please feel free to let me know.
>
> Sincerely,
> Linda Liu
> Microsoft Online Community Support
>
Yes, that makes sense and is what I finally determined had to be the case.
It would be good if the help said something like this and if there was an
example that pointed out the use of the xml document as part of the
databinding. When doing data binding with expression blend it 'looks' like
you are binding directly to the xml file. I did finally change the binding
to use the xml to linq xelement as a data source and manually read and saved
the file when I wanted to from code.
My System SpecsSystem Spec