title: how to bind combobox selection changed value with listbox items?
body: <p>I have created ListBox with dynamically adding items to it. how to add List items binded with ComboBoxItem value. If the combobox selection was 2, i need only 2 list items seen in the ListBox. Implementing MVVM and InotifyPropertyChanged to ComboBox is the best practice i think. Please help.</p>
  
  <pre><code>     public partial class MainWindow : Window
              {
                  public List&lt;VisibleItem&gt; dataList { get; set; }
  
                  public MainWindow()
                  {
                      InitializeComponent();
                      LoadListItems();
                  }
     public class VisibleItem
      {
          public int PictureID { get; set; }
          public string Name { get; set; }
          public string SomeDetail { get; set; }
          public string Info { get; set; }
          public string Group { get; set; }
          public string GHeaderName { get; set; }
          public string bindText { get; set; }
          public object Class2 { get; internal set; }
      }
  
                  //load list to the ListBox
                  private void LoadListItems()
                  {
                      dataList = new List&lt;VisibleItem&gt;();
                      dataList = getDataList();
                      ListBoxConverter.ItemsSource = dataList;
                      this.ListBoxConverter.DataContext = this;
                  }        
  
                  //creating sample item list
                  private List&lt;VisibleItem&gt; getDataList()
                  {
                      VisibleItem vItem;
  
                      for (var k = 1; k &lt; 10; k++)
                      {
                          vItem = new VisibleItem();
                          vItem.Group = "Group " + k;
                          vItem.Name = "Item Name  " + k;
                          vItem.PictureID = k;
                          vItem.SomeDetail = "Detail  " + k;
                          vItem.Info = "Info  " + k;
                          vItem.GHeaderName = "GHeaderName " + k;  
                          vItem.Info = "Info  " + k;
                         // vItem.Class
                          dataList.Add(vItem);
                      }
                      return dataList;
                  }
  
              }
  </code></pre>
  
  <hr>
  
  <pre><code>  //xaml   
  
   &lt;Window.Resources&gt;
              &lt;local1:ComboBox x:Key="ImageConverter"/&gt;
              &lt;DataTemplate x:Key="DataTemplateItemConverter"&gt;
                  &lt;GroupBox x:Name="Group" Header="{Binding GHeaderName}" Height="45" Width="720" Canvas.Top="52" Background="#FFD8D8D8" BorderBrush="Black"&gt;
                      &lt;Canvas Height="48" Margin="0,0,-2,-9"&gt;
                          &lt;!--&lt;Image Source="{Binding PictureID,Converter={StaticResource ImageConverter}}" Name="ImageName" Height="36" Width="36" Canvas.Left="8" Canvas.Top="8"&gt;&lt;/Image&gt;--&gt;
                          &lt;TextBlock x:Name="Names" Text="{Binding Name}" Canvas.Left="124" Width="109" Height="22"/&gt;
  
                          &lt;TextBlock x:Name="Some" Text="{Binding SomeDetail}" Canvas.Left="272" Width="120" Height="22"/&gt;
                          &lt;TextBox x:Name="Information" Text="{Binding Info}" Width="102" /&gt;
                          &lt;TextBox x:Name="bindText" Text="{Binding Info, Mode=OneWay}" Width="126" Canvas.Left="414"/&gt;
                      &lt;/Canvas&gt;
                  &lt;/GroupBox&gt;
              &lt;/DataTemplate&gt;
          &lt;/Window.Resources&gt;
          &lt;Canvas&gt;        
  
              &lt;ComboBox x:Name="ComboBox1" Canvas.Left="166" Canvas.Top="5" Width="68" SelectionChanged="ComboBox_SelectionChanged"&gt;
                  &lt;ComboBoxItem IsSelected="True" Content="1"/&gt;
                  &lt;ComboBoxItem Content="2"/&gt;
                  &lt;ComboBoxItem Content="3"/&gt;
                  &lt;ComboBoxItem Content="4"/&gt;
                  &lt;ComboBoxItem Content="5"/&gt;
                  &lt;ComboBoxItem Content="6"/&gt;
              &lt;/ComboBox&gt;
  
              &lt;ListBox x:Name="ListBoxConverter" ItemTemplate="{DynamicResource DataTemplateItemConverter}" ItemsSource="{Binding dataList}" IsSynchronizedWithCurrentItem="True" HorizontalContentAlignment="Left" Background="{x:Null}" BorderBrush="{x:Null}" Height="295" Canvas.Left="-8" Canvas.Top="31" Width="541"&gt;
  
              &lt;/ListBox&gt;
  
  
          &lt;/Canvas&gt;
  
      &lt;/Window&gt;
  </code></pre>