title: WPF ListBox Multi-Select binding
body: <p>I have two listBoxes one on the left and one on the right. When I select a 'contactList' item on the left listBox the 'label' information should be displayed on the right listBox and this part works fine. The problem I am having is to do with multi-select because at the moment it will only display the information from one selection. I changed Selection mode in my XAML to multi-select but that did not seem to work. Would appreciate any assistance. Thanks.</p>
  
  <p><strong>XAML</strong></p>
  
  <pre><code>&lt;Grid x:Name="LayoutRoot" Background="#FFCBD5E6"&gt;
      &lt;ListBox x:Name="contactsList" SelectionMode="Multiple" Margin="7,8,0,7" ItemsSource="{Binding ContactLists, Mode=Default}" ItemTemplate="{DynamicResource ContactsTemplate}" HorizontalAlignment="Left" Width="254" SelectionChanged="contactsList_SelectionChanged"/&gt;
      &lt;ListBox x:Name="tagsList" Margin="293,8,8,8" ItemsSource="{Binding AggLabels, Mode=Default}" ItemTemplate="{StaticResource TagsTemplate}" Style="{StaticResource tagsStyle}" /&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <pre><code>private void contactsList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
      {
          if (contactsList.SelectedItems.Count &gt; 0)
          {
              CollectionViewGroup collectionView = contactsList.SelectedItems[0] as CollectionViewGroup;
              ContactList selectedContact = contactsList.SelectedItems[0] as ContactList;
  
              ObservableCollection&lt;AggregatedLabel&gt; labelList = new ObservableCollection&lt;AggregatedLabel&gt;();
  
              foreach (ContactList contactList in collectionView.Items)
              {
                  foreach (AggregatedLabel aggLabel in contactList.AggLabels)
                  {
                      labelList.Add(aggLabel);
  
                      tagsList.ItemsSource = labelList;
  
                  }
  
              }
          }
      }
  </code></pre>