Hello,
We are using a TreeView to display a directory hierarchy; the data comes as json from a server. We have a TreeView that is working very well for an arbitrarily deep dir structure:
<sdk:TreeView x:Name="uploaderTree" ItemsSource="{Binding Items}" >
<sdk:TreeView.ItemTemplate>
<sdk:HierarchicalDataTemplate ItemsSource="{Binding Children}" >
<TextBlock Text="{Binding Name}" />
</sdk:HierarchicalDataTemplate>
</sdk:TreeView.ItemTemplate>
</sdk:TreeView>
However, we need to handle the Expanded event (or, at least, bind TwoWay to the IsExpanded property). Also, we need to keep track of the SelectedItem in the TreeView.
Can someone suggest a way to combine that requirement -- handle the Expanded event and SelectedItem -- with the use of the HierarchicalDataTemplate? I have been going around in circles with ControlTemplate, ItemTemplate, DataTemplate, Style, etc...
Thanks for any ideas...
(I'm doing all the work in code-behind right now, which is a real mess compared to doing the work in the ViewModel and letting the databinding sort it out!)