Hi all,

I've implemented a tree and have bound it to my treeview. the binding is fine, but id like to add "add child" "remove node" functionality in a context menu for a selected item. I can not for the life of me figure out how to do this. My code is below. please help me. please point me in the right direction.

<TreeView Name="treeView" Margin="10,10,14,10" BorderThickness="2" ItemsSource="{Binding Nodes}">

<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FF332187" Offset="0" />
<GradientStop Color="Transparent" Offset="1" />


<HierarchicalDataTemplate ItemsSource="{Binding Nodes}">

<TextBlock Text="{Binding title}" PreviewMouseRightButtonUp="createContextMenu"/>



my tree implementation:

public class Node
private ObservableCollection<Node> _nodes;
public string title { get; set; }
public string content { get; set; }

public Node(string _title)
title = _title;
_nodes = new ObservableCollection<Node>();

public ObservableCollection<Node> Nodes
if (_nodes == null)
_nodes = new ObservableCollection<Node>();

return _nodes;

_nodes = value;