Retrive treeview item

Posted by Anu on Stack Overflow See other posts from Stack Overflow or by Anu
Published on 2010-04-20T05:08:46Z Indexed on 2010/04/20 5:13 UTC
Read the original article Hit count: 338

Filed under:
|

Hi, In y treeview i have text,after i seelcted that,i want to retrive that selected item as string and i need to pass this string to various fucntions.

I dont know how to get the selected item.I coded like

private void treeview1_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            TreeViewItem selectedTVI = null;
            if (treeview1.SelectedItem != null)
            {
                selectedTVI = treeview1.Tag as TreeViewItem;
            }
        }

But selectedTVi shows NULL.What can i do?

© Stack Overflow or respective owner

Related posts about treeview

Related posts about wpf