D
dave
I am trying to link to some simple xml data in a local file...
<dataroot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DisplayName>Line Rate</DisplayName>
<Location>Line test change</Location>
</dataroot>
I have tried a couple ways, but right now have this in the xaml:
<Window.Resources>
<XmlDataProvider x:Key="datarootDS" Source="C:\demo\test.xml"
d:IsDataSource="True"/>
</Window.Resources>
<Window.DataContext>
<Binding Mode="TwoWay" Source="{StaticResource datarootDS}"
XPath="/dataroot" />
</Window.DataContext>
then the control looks like:
<TextBox Margin="0,0,0,0" Grid.Column="1" Text="{Binding Mode=TwoWay,
UpdateSourceTrigger=LostFocus, XPath=/dataroot/Location}" TextWrapping="Wrap"
HorizontalAlignment="Stretch" TextChanged="OnTextBoxChanged"/>
I get data from the xml to the control just fine on startup, but it doesn't
save changes from the control back to the xml file. am i missing something
in the link back to the xml file? i have also tried the explicit trigger
and manually calling the updatesource function but it still doesn't get
written back to the file.
<dataroot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DisplayName>Line Rate</DisplayName>
<Location>Line test change</Location>
</dataroot>
I have tried a couple ways, but right now have this in the xaml:
<Window.Resources>
<XmlDataProvider x:Key="datarootDS" Source="C:\demo\test.xml"
d:IsDataSource="True"/>
</Window.Resources>
<Window.DataContext>
<Binding Mode="TwoWay" Source="{StaticResource datarootDS}"
XPath="/dataroot" />
</Window.DataContext>
then the control looks like:
<TextBox Margin="0,0,0,0" Grid.Column="1" Text="{Binding Mode=TwoWay,
UpdateSourceTrigger=LostFocus, XPath=/dataroot/Location}" TextWrapping="Wrap"
HorizontalAlignment="Stretch" TextChanged="OnTextBoxChanged"/>
I get data from the xml to the control just fine on startup, but it doesn't
save changes from the control back to the xml file. am i missing something
in the link back to the xml file? i have also tried the explicit trigger
and manually calling the updatesource function but it still doesn't get
written back to the file.