Display editable values in TreeView



I am using WPF to create a TreeView display that shows an XML file. I want all of the treeview to be in editable text boxes. I have managed to make it so my parent node is editable, but the child is not. For example, I have an Xml with Variables, a parent node, and values. The XML looks like this,



'<variables>
<ParentNode>
<DataSource>a</DataSource>
<Catalog>b</Catalog>
<User>c</User>
<Password>d</Password>
</variables>'


I have managed to make my WPF output the following that expands and collapses, however a, b and c are not editable.



'+Variables`


changes to



`-Variables
-ParentNode
a
b
c`


I am able to do this through XAML with the following code.



'<Window x:Class="TreeView2.MainWindow"
xmlns="http://ift.tt/o66D3f"
xmlns:x="http://ift.tt/mPTqtT"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<XmlDataProvider x:Key="MyList" Source="C:\CAD.Services\MASTER.xml" XPath="variables" />


<HierarchicalDataTemplate DataType="variables" ItemsSource="{Binding XPath=*}">
<TextBox FontSize="25" Foreground="Black" Text="variables"></TextBox>
</HierarchicalDataTemplate>

<HierarchicalDataTemplate DataType="ParentNode" ItemsSource="{Binding XPath=*}">
<TextBox FontSize="16" Text="ParentNode"></TextBox>
</HierarchicalDataTemplate>

<Grid>
<DockPanel>
<TreeView DockPanel.Dock="Left" Width="250" Name="treeViewPackages"
ItemsSource="{Binding Source={StaticResource MyList}}">
</TreeView>
<Grid DockPanel.Dock="Right">
</Grid>
</DockPanel>`


I am trying to make it so A B C would be editable like the rest of the options. However I am unsure of how to go about making this happen. They are displayed fine, but are not located inside a text box.


Any help would be greatly appreciated.


No comments:

Post a Comment