title: Two way binding is not happening between Tree view and combo box in WPF
body: <p>I have a user control which has  a tree view and a combo box.Tree view  has items source bound  using view model class.Combo box item source is given through code behind.I have bound Selected Id path  as two way binding between Combo box and tree view.Now when application run, when  control has populated and displayed data and when ever I select any item in Treeview..combox box item is getting selected.But when I select any item from combo box , corresponding item is not getting selected in the treeview..though it two way binding..please help me to fix this issue ..my objective is when ever user select any item in combo box , the same item should be selected in tree view
  My User control :</p>
  
  <pre><code>  &lt;UserControl x:Class="gsktid.MyUserControl.TreeView"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
           mc:Ignorable="d" 
               xmlns:local="clr-namespace:gsktid.MyUserControl"
            xmlns:local1="clr-namespace:gsktid.ViewModel" 
            xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"&gt;
  
  &lt;StackPanel&gt;
      &lt;TextBlock HorizontalAlignment="Left" Margin="20,0,0,0" Width="Auto" Text="Search:" TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Arial"/&gt;
      &lt;ComboBox x:Name="cmbSerchBox" Width="120" DisplayMemberPath = "FirstName"  SelectedIndex = "-1"   SelectedValuePath = "Id"  SelectedValue="{Binding  Path=SelectedId,Mode=TwoWay}"   HorizontalAlignment="Left" Margin="8"  &gt;
    Path=SelectedId}"/&gt;
          &lt;/i:EventTrigger&gt;--&gt;
      &lt;/ComboBox&gt;
      &lt;TreeView Height="500" x:Name="tvMain" ItemsSource="{Binding Root}" BorderThickness="0" ScrollViewer.VerticalScrollBarVisibility="Visible"&gt;
          &lt;TreeView.ItemTemplate&gt;
              &lt;HierarchicalDataTemplate ItemsSource="{Binding Children}"&gt;
                  &lt;StackPanel Orientation="Horizontal"&gt;
                      &lt;Image Source="{Binding ImagePath}" MaxHeight="25" MaxWidth="25"/&gt;
                      &lt;TextBlock VerticalAlignment="Center"&gt;            
                      &lt;TextBlock.Text&gt;
                          &lt;MultiBinding StringFormat=" {0} "&gt;
                              &lt;Binding Path="FirstName"/&gt;
  
                          &lt;/MultiBinding&gt;
                      &lt;/TextBlock.Text&gt;
                      &lt;/TextBlock&gt;
                      &lt;StackPanel.Style&gt;
                          &lt;Style&gt;
                              &lt;Style.Triggers&gt;
                                  &lt;DataTrigger Binding="{Binding IsSelected}" Value="true"&gt;
                                      &lt;Setter Property="StackPanel.Background" Value="LightBlue"/&gt;
                                  &lt;/DataTrigger&gt;
                              &lt;/Style.Triggers&gt;
                          &lt;/Style&gt;
                      &lt;/StackPanel.Style&gt;
                  &lt;/StackPanel&gt;
              &lt;/HierarchicalDataTemplate&gt;
          &lt;/TreeView.ItemTemplate&gt;
          &lt;TreeView.ItemContainerStyle&gt;
              &lt;Style TargetType="{x:Type TreeViewItem}"&gt;
                  &lt;Setter Property="IsExpanded" Value="True"/&gt;
                  &lt;Setter Property="IsSelected" Value="{Binding IsSelected}"/&gt;
              &lt;/Style&gt;
          &lt;/TreeView.ItemContainerStyle&gt;
          &lt;i:Interaction.Triggers&gt;
              &lt;i:EventTrigger EventName="SelectedItemChanged"&gt;
                  &lt;i:InvokeCommandAction Command="{Binding SelectedCommand}" 
                                         CommandParameter="{Binding ElementName=tvMain, Path=SelectedItem}"/&gt;
              &lt;/i:EventTrigger&gt;
          &lt;/i:Interaction.Triggers&gt;
      &lt;/TreeView&gt;
  
  
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p></p>
  
  <p>My code behind of this user control is :</p>
  
  <pre><code>using System.Linq;
  using System.Text;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  using gsktid.ViewModel;
  using gsktid.Model;
  namespace gsktid.MyUserControl
   {
  
       public partial class TreeView : UserControl
  {
      public TreeView()
      {
          InitializeComponent();
          this.DataContext = OrgTreeViewModel.Instance();
          cmbSerchBox.ItemsSource = OrgChartManager.Instance().GetChildrenSerch();
  
      }
  }      
  </code></pre>
  
  <p>}</p>
  
  <hr>
  
  <p>Here Combobox is poulated wit dataset by giving the item source in code behind.But Treeview 's item source is populated through view model data set.Both data set is having one common key .That is how the when I select the item in the tree view corresponding item in the combo box is getting selected.But vice versa is not happening.When I select one item in the combo box , the corresponding item in the tree view is getting selected even though it two way binding</p>
  
  <p>What I have tried:</p>
  
  <p>I have tried to bind between combo box and Tree view..as two way binding  ..but it is working one way .when   ever I makes selection changes in Treeview it is reflecting in the combo  box..but when I makes selection changes in the combo box it is not affecting tree view</p>