How to click treeview node more than once consecutively - treeview bound to datatable RRS feed

  • Question

  • I have a treeview in my WPF:


     ItemsSource="{Binding ParentNode}"
     ItemTemplate="{StaticResource NavigationMenuTemplate}" 
     TreeViewItem.Selected="treeViewAppMenu_Selected"  Margin="2"
    ScrollViewer.HorizontalScrollBarVisibility="Auto"        ScrollViewer.VerticalScrollBarVisibility="Auto"


    I can get the value from the selected node.

    The problem that I'm having is that i cannot click the same node more than once consecutively. I thought that it is because the node is already selected so it won't let me set it again.  So in my method "treeViewAppMenu_Selected", I find the selected treeviewitem and set isSelected = false.  I tried this and even though the node isSelected = false, I still cannot click on the same node more than once consecutively.

    Just to clarify, I bind a datatable to the treeview. I think this is where I'm messing up because if I created a straight bind to the treeview, I can set the isSelected = false and it work.  There's where the problem is. UGH!

    Any suggestions are welcomed. Thanks!

    Friday, July 15, 2011 5:10 PM


  • I got a quick work-around that works.  I'm not sure if I would consider this the proper answer though.

    When the treeViewAppMenu_Selected is called, i set the focus on another control.  In my case, a label. 

    So...the treeViewItem loses focus and I can select it again.

    Dirty I guess..but it works for now.

    Any other suggestions are still very much welcomed!



    • Marked as answer by GreenWasabi Saturday, July 16, 2011 8:42 PM
    Saturday, July 16, 2011 8:41 PM