I have a wpf apllication based on MVVM software archhitecture. It consist of treeView and ListView. When a treeView Node is clicked, all the child nodes of that node are displayed in the listview. I am able to achieve this part.
But whent the user click an item from the listView, that particular item (which is a node in treeview) should get selected in the treeView. I dont know how to do this. Basically I want to bind property SelectedItem to listview selected item. but it seems like treeview selectedItem propeerty is readonly.
<TreeView Name="tv" ItemsSource="{Binding ChildAndAttributes}" VerticalAlignment="Stretch" Margin="12,12,12,35">
<TreeView.Resources>
<DataTemplate DataType="{x:Type tvcc:NodeViewModel}">
<TextBlock Text="{Binding Text}" />
</DataTemplate>
<DataTemplate DataType="{x:Type tvcc:NodeAttributeViewModel}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding AttributeName}" />
<TextBlock Text="{Binding AttributeValue}" Padding="2,0,0,0" Foreground="Blue" />
</StackPanel>
</DataTemplate>
</TreeView.Resources>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding ChildAndAttributes}">
<ContentControl Content="{Binding}" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>