title: Including objects binding in MultiBinding command parameter
body: <p>I am attempting to use a <code>&lt;MultiBinding&gt;</code> to pass two parameters to my ViewModel's command but am having issues getting the XAML parser to accept my attempts.  </p>
  
  <p>Consider the following ListView contained within my <code>UserControl</code> which is bound to a collection of <code>Ticket</code> objects.</p>
  
  <pre><code>&lt;ListView x:Name="lvTicketSummaries" 
                    ItemsSource="{Binding TicketSummaries}"  
                    ItemContainerStyle="{DynamicResource ResourceKey=ListViewItem}"
                    IsSynchronizedWithCurrentItem="True"&gt;
  </code></pre>
  
  <p>The respective style <code>ListViewItem</code></p>
  
  <pre><code>&lt;Style x:Key="ListViewItem" TargetType="{x:Type ListViewItem}"&gt;
      &lt;Setter Property="ContextMenu" Value="{DynamicResource ResourceKey=cmListViewItem}"/&gt;
      &lt;!-- A load of irrelevant stuff -&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>And the referenced <code>ContextMenu</code>  item where the source of my query sits;</p>
  
  <pre><code>&lt;!-- ContextMenu DataContext bound to UserControls view model so it can access 'Agents' ObservableCollection --&gt;    
  &lt;ContextMenu x:Key="cmListViewItem" DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=DataContext}"&gt;
      &lt;MenuItem Header="Send as Notification" ItemsSource="{Binding Path=Agents}"&gt;
          &lt;MenuItem.ItemContainerStyle&gt;
              &lt;Style TargetType="{x:Type MenuItem}"&gt;
                  &lt;!-- Display the name of the agent (this works) --&gt;
                  &lt;Setter Property="Header" Value="{Binding Path=Name}"/&gt;
                  &lt;!-- Set the command to that of one on usercontrols viewmodel (this works) --&gt;
                  &lt;Setter Property="Command" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Path=DataContext.SendTicketNotification}" /&gt;
                  &lt;Setter Property="CommandParameter"&gt;
                      &lt;Setter.Value&gt;
                          &lt;MultiBinding Converter="{StaticResource ResourceKey=TicketNotificationParameterConverter}"&gt;
                              &lt;MultiBinding.Bindings&gt;
                                  &lt;!-- This SHOULD be the Agent object I clicked on to trigger the Command. This does NOT work, results in either exception or 'UnsetValue' --&gt;
                                  &lt;Binding Source="{Binding}" /&gt;
                                  &lt;!-- Also pass in the Ticket item that was clicked on to open the context menu, this works fine --&gt;
                                  &lt;Binding RelativeSource="{RelativeSource AncestorType={x:Type ListView}}" Path="SelectedItem" /&gt;
                              &lt;/MultiBinding.Bindings&gt;
                          &lt;/MultiBinding&gt;
                      &lt;/Setter.Value&gt;
                  &lt;/Setter&gt;
              &lt;/Style&gt;
          &lt;/MenuItem.ItemContainerStyle&gt;
      &lt;/MenuItem&gt;
  &lt;/ContextMenu&gt;
  </code></pre>
  
  <p>So here is what I am attempting to do;</p>
  
  <ul>
  <li><p>The context menu has a single item "Send ticket as notification" which, when selected, lists all the available <code>Agents</code> which can receive said notification. This works.</p></li>
  <li><p>When I click on one of these agent options, I want the context menu item to send both the <code>ticket</code> item that was clicked on from the <code>listview</code> to show the context menu (this works) AND the <code>Agent</code> item I selected from the context menu.  I have half-achieved this with the <code>MultiBinding</code> </p>
  
  <pre><code>&lt;MultiBinding Converter="{StaticResource ResourceKey=TicketNotificationParameterConverter}"&gt;
                          &lt;MultiBinding.Bindings&gt;
                              &lt;!-- This works, it sends the Ticket object to the Converter --&gt;
                              &lt;Binding RelativeSource="{RelativeSource AncestorType={x:Type ListView}}" Path="SelectedItem" /&gt;
                              &lt;!-- This caused an exception saying that I can only set 'Path' property on DependencyProperty types --&gt;
                              &lt;Binding Path="{Binding}" /&gt;
                          &lt;/MultiBinding.Bindings&gt;
                      &lt;/MultiBinding&gt;
  </code></pre></li>
  </ul>
  
  <p>Now although the actual set-up of the context menu seems some what complicated to me.  The actual specification that one of the <code>MultiBinding</code> parameters should be the actual item bound to the clicked <code>ContextMenu.MenuItem</code> seems quite a simple command.  The context menu correctly lists all Agents and so I would of thought that simply asking for this current object to be sent through as a command parameter, simple.  I have also tried;</p>
  
  <pre><code>&lt;Binding RelativeSource={RelativeSource AncestorType={x:Type MenuItem}} Path="SelectedItem" /&gt;
  </code></pre>
  
  <p>as well as </p>
  
  <pre><code>&lt;Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}} Path="SelectedItem" /&gt;
  </code></pre>
  
  <p>But all that gets sent to the Parameter converter is <code>UnsetValue</code></p>
  
  <p>Thank you for your time and any suggestions you might have.</p>