TreeView node editing

1 posts, 0 answers
  1. Timothy Lee Russell
    Timothy Lee Russell avatar
    20 posts
    Member since:
    Feb 2003

    Posted 22 Oct 2008 Link to this post

    I am having no luck trying to create a editable node.  I am using XmlDataProvider and HierarchicalDataTemplates.

    I have set IsEditable to True on the TreeView.

    My DataTemplates look like this:

            <HierarchicalDataTemplate DataType="forest" ItemsSource="{Binding XPath=tree}"
                <StackPanel> 
                    <TextBlock Text="{Binding XPath=@name}" MouseDown="Node_MouseDown" /> 
                </StackPanel> 
            </HierarchicalDataTemplate> 
            <HierarchicalDataTemplate DataType="tree" ItemsSource="{Binding XPath=branch}"
                <StackPanel> 
                    <TextBlock Text="{Binding XPath=@name}" MouseDown="Node_MouseDown" /> 
                </StackPanel> 
            </HierarchicalDataTemplate> 
            <HierarchicalDataTemplate DataType="branch" ItemsSource="{Binding XPath=leaf}"
                <StackPanel> 
                    <TextBlock Text="{Binding XPath=@name}" MouseDown="Node_MouseDown" /> 
                </StackPanel> 
            </HierarchicalDataTemplate> 
            <DataTemplate DataType="leaf"
                <StackPanel> 
                    <TextBlock Text="{Binding XPath=@name}" MouseDown="Node_MouseDown" /> 
                </StackPanel> 
            </DataTemplate> 

    If I press F2 while on a node, I get a textbox that pops up on top -- but it says
    System.Xml.XmlElement.  I need to somehow get it bound to @name so that the two-way binding will function.

    If I replace the text on my last node (the leaf) in the edit box (this is on the DataTemplate), then the TextBlock node shows up blank from then on but doesn't save it so it's not making it back to the XmlDataProvider .

    If I edit the text on one of the HierarchicalDataTemplates, it seems to have no effect.

    Thanks,
    Timothy


Back to Top