title: Binding textbox text to a xml file in wpf
body: <p>I am new to WPF programming. Please help me here.</p>
  
  <p>I want the data entered in textboxes to be updated in the xml file. Here is my code.</p>
  
  <p>xaml:</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;XmlDataProvider x:Key="credential_data" Source="Credentials.xml" XPath="/Credentials/MB"/&gt;
  &lt;/Window.Resources&gt;
  
  
       &lt;StackPanel DataContext="{Binding Source={StaticResource credential_data}}"&gt;                            
                &lt;TextBox Height="23" Name="textBox5" Width="188" Text="{Binding XPath=Hostname, Mode=TwoWay}"/&gt;
                &lt;TextBox Height="23" Name="textBox6" Width="188" Text="{Binding XPath=Port, Mode=TwoWay}"/&gt;
      &lt;/StackPanel&gt;
  </code></pre>
  
  <p>Here is Credentials.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Credentials&gt;
      &lt;MB&gt;
          &lt;Hostname&gt;10.111.123.234&lt;/Hostname&gt;
          &lt;Port&gt;8080&lt;/Port&gt;
      &lt;/MB&gt;
  &lt;/Credentials&gt;
  </code></pre>
  
  <p>What is happening now is that any updates in the xml file gets reflected in the textboxes but any changes in textbox.text does not update the xml file.</p>
  
  <p>where am I going wrong?? :(</p>
  
  <p>Thanks.</p>