TreeView
in WPF has a property called SelectedItem
.
TreeViewItem selectedTVI = (TreeViewItem)myTreeView.SelectedItem;
selectedTVI.Items.Add(newChild);
You should read the documentation. SelectedValue
is the "value of the property that is the specified by SelectedValuePath for the SelectedItem", not the actual SelectedItem
which I've shown above.