Having an issue with selection of my treeview. The idea is that the user clicks the item and data is added under the node that they selected
public MainWindow()
{
InitializeComponent();
this.UserControl1.TreeView1.SelectedItemChanged += new RoutedPropertyChangedEventHandler<Object>(InterfaceTreeViewComputers_SelectionChange);
}
void InterfaceTreeViewComputers_SelectionChange(Object sender, RoutedPropertyChangedEventArgs<object> e)
{
var MyTreeView = MainWindow.UserControl1.Treeview1.Items.SourceCollection;
var TheSource = sender as TreeView;
var TheProperty = e.Source;
var ThePropertyAsTreeView = TheProperty as TreeView
TreeViewItem item = e.OriginalSource as TreeViewItem; //Equals Null
var Attempt2 = ThePropertyAsTreeView.SelectedItem //Equals Null
var Attempt3 = TheSource.SelectedItem as TreeViewItem //Equals Null
var Attempt4 = TheSource.SelectedItem //Equals onbject(String)
}
It seems that the selected item is a textblock and i cant seem to find a way to get it as a treeview item to add nodes under it.
Yes i am pretty new to this type of programming.
Thank you for any help you may provide.