This is a migrated thread and some comments may be shown as answers.

TreeView node editing

0 Answers 64 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Timothy Lee Russell
Top achievements
Rank 2
Timothy Lee Russell asked on 22 Oct 2008, 10:22 PM
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


No answers yet. Maybe you can help?

Tags
TreeView
Asked by
Timothy Lee Russell
Top achievements
Rank 2
Share this question
or