Making selectable again a WPF TreeviewITem after the first click
- by pileggi
Hi,
I have a TreeVIew WPF with 2 Levels of Data.
I have deleted the ToogleButton from the TreeViewItemTemplate. Now I'd like to expand / collapse the groups with a single mouse-click (not with a double click as the default behaviour).
I have tried in this way:
Private Sub tvArt_SelectedItemChanged(ByVal sender As System.Object, _
ByVal e As RoutedPropertyChangedEventArgs(Of System.Object)) Handles tvArt.SelectedItemChanged
If e.NewValue Is Nothing = False Then
Dim ri As P_RicambiItem = TryCast(e.NewValue, P_RicambiItem)
If ri Is Nothing = False Then
If ri.isExpanded Then
ri.isExpanded = False
Else
ri.isExpanded = True
End If
ri.isSelected = False
End If
End If
End Sub
Using my properties "isExpanded" and "isSelected" in the collection data source. But it works only halfway: after the first click, infact, I can't click for a second time on the same item, because, even if I've deselected it, the event handler "remembers" that it was the last selected item and it doesn't capture the event "SelectedItemChanged".
How can I do?
Thanks a lot,
Pileggi