title: prism 5.0 InvokeCommandAction SelectionMode="Multiple"
body: <p>I want to detect all selected items in List Box through InvokeCommandAction  prism 5.0.</p>
  
  <p><strong>XAML</strong>:</p>
  
  <pre><code>&lt;Window x:Class="Selection.Prism5._0.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
      xmlns:local="clr-namespace:Selection.Prism5"
      xmlns:prism="http://www.codeplex.com/prism"
      mc:Ignorable="d"
      Title="MainWindow"
      Height="350"
      Width="525"&gt;
  &lt;FrameworkElement.DataContext&gt;
      &lt;local:MainViewModel /&gt;
  &lt;/FrameworkElement.DataContext&gt;
  &lt;Grid&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="2*" /&gt;
          &lt;ColumnDefinition Width="5" /&gt;
          &lt;ColumnDefinition Width="3*" /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;ListBox SelectedItem="{Binding SelectedItem}"
               ItemsSource="{Binding Items}"
               SelectionMode="Multiple"&gt;
          &lt;i:Interaction.Triggers&gt;
              &lt;i:EventTrigger EventName="SelectionChanged"&gt;
                  &lt;prism:InvokeCommandAction Command="{Binding SelectItemsCommand}"
                                             TriggerParameterPath="AddedItems" /&gt;
              &lt;/i:EventTrigger&gt;
          &lt;/i:Interaction.Triggers&gt;
  
          &lt;ListBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;TextBlock Text="{Binding Name}" /&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
      &lt;/ListBox&gt;
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>View Model</strong>:</p>
  
  <pre><code>  public class MainViewModel : BindableBase
  {
      public MainViewModel()
      {
          this.Items = new List&lt;Model&gt;
          {
             new Model {Id=1,Name="Name 1" },
             new Model {Id=2,Name="Name 2" },
             new Model {Id=3,Name="Name 3" },
             new Model {Id=4,Name="Name 4" },
             new Model {Id=5,Name="Name 5" },
             new Model {Id=6,Name="Name 6" }
          };
          SelectItemsCommand = new DelegateCommand&lt;object[]&gt;((items) =&gt;
          {
              if (items != null &amp;&amp; items.Count() &gt; 0)
              {
                  SelectedItems = items.Select(i =&gt; (Model)i);
              }
          });
  
      }
  
  
  
      public ICommand SelectItemsCommand { get; private set; }
  
      private IEnumerable&lt;Model&gt; _items;
      public IEnumerable&lt;Model&gt; Items
      {
          get { return _items; }
          set
          {
              _items = value; base.OnPropertyChanged("Items");
          }
      }
  
  
      private IEnumerable&lt;Model&gt; _selectedItems;
      public IEnumerable&lt;Model&gt; SelectedItems
      {
          get { return _selectedItems; }
          set
          {
              _selectedItems = value; base.OnPropertyChanged("SelectedItems");
          }
      }
      private Model _selectedItem;
      public Model SelectedItem
      {
          get { return _selectedItem; }
          set
          {
              _selectedItem = value; base.OnPropertyChanged("SelectedItem");
          }
      }
  }
  </code></pre>
  
  <p>It should work, however it doesn't. When I select more than one item in GUI:</p>
  
  <p><a href="https://i.stack.imgur.com/Ej9w9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ej9w9.png" alt="enter image description here"></a></p>
  
  <p>View model code recognizes only one item:</p>
  
  <p><a href="https://i.stack.imgur.com/DdgDC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DdgDC.png" alt="enter image description here"></a></p>
  
  <p>I saw this example in <a href="https://app.pluralsight.com/library/courses/prism-50-whats-new/table-of-contents" rel="nofollow noreferrer">"What's New in Prism 5.0"</a> by Brian Lagunas and as far as I understood, this technic may be used for multi-selection too.
  What have I done wrong here?</p>