i have a xml like this:
<root>
<settings>
....
...
..
</settings>
<cards>
<card name="firstcard">
<question>bla</question>
<answer>blub</answer>
</card>
<card name="nextcard">
<question>bla</question>
<answer>blub</answer>
</card>
</cards>
</root>
and i would bind it to a treeview that shows me the cards with their names and subitems. Also i would bind this to a textbox to edit the nodes (question, answer). I have found a description on stackoverflow: Two-way binding of Xml data to the WPF TreeView but i can´t change it to my needs :-( below is my last try:
<Window.Resources>
<HierarchicalDataTemplate DataType="cards" ItemsSource="{Binding XPath=card}">
<TextBox Text="cards" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="card">
<StackPanel>
<TextBox Text="{Binding XPath=question}"></TextBox>
<TextBox Text="{Binding XPath=answer}" Margin="0,0,0,15"></TextBox>
</StackPanel>
</HierarchicalDataTemplate>
<XmlDataProvider x:Key="dataxml" XPath="root/cards" Source="path\cards.xml" />
</Window.Resources>
..
...
<Label Content="question:"/>
<TextBox DataContext="{Binding ElementName=treeView, Path=SelectedItem}"
Text="{Binding XPath=question, UpdateSourceTrigger=PropertyChanged}"/>
<Label Content="answer:"/>
<TextBox DataContext="{Binding ElementName=treeView, Path=SelectedItem}"
Text="{Binding XPath=answer, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
<Grid>
<TreeView Name="treeView" ItemsSource="{Binding Source={StaticResource dataxml}, XPath=.}" />
</Grid>