I am new to WPF programming. Please help me here.
I want the data entered in textboxes to be updated in the xml file. Here is my code.
xaml:
<Window.Resources>
<XmlDataProvider x:Key="credential_data" Source="Credentials.xml" XPath="/Credentials/MB"/>
</Window.Resources>
<StackPanel DataContext="{Binding Source={StaticResource credential_data}}">
<TextBox Height="23" Name="textBox5" Width="188" Text="{Binding XPath=Hostname, Mode=TwoWay}"/>
<TextBox Height="23" Name="textBox6" Width="188" Text="{Binding XPath=Port, Mode=TwoWay}"/>
</StackPanel>
Here is Credentials.xml :
<?xml version="1.0" encoding="utf-8"?>
<Credentials>
<MB>
<Hostname>10.111.123.234</Hostname>
<Port>8080</Port>
</MB>
</Credentials>
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.
where am I going wrong?? 🙁
Thanks.
Sorry for not giving you a full example, but this CodeProject already has a tutorial project that does exactly what you want