title: How to pass MenuItem as command parameter for its child control
body: <p>I have something like below. For <code>MenuItem</code>, here I am passing an object of that <code>MenuItem</code> as a <code>CommandParameter</code>. This works fine for me. My <code>MenuItem</code> holds a <code>RadioButton</code> and I want to use the MenuItem <code>CommandParameter</code> value for this <code>RadioButton</code>. Could anyone please help me how to do this. Thanks in Advance.</p>
  
  <pre><code>&lt;MenuItem Header="Name"
            VerticalAlignment="Center"
            VerticalContentAlignment="Center"
            Command="{Binding SortCommand}"
            CommandParameter="{Binding RelativeSource={RelativeSource Self}}"&gt;
        &lt;MenuItem.Icon&gt;
             &lt;RadioButton VerticalAlignment="Center"
                          Margin="3"
                          IsChecked="True"
                          GroupName="sort"
                          Command="{Binding SortCommand}"
                          CommandParameter="..." /&gt;
        &lt;/MenuItem.Icon&gt;
  &lt;/MenuItem&gt;
  </code></pre>
  
  <p>Now <code>Command</code> is executing only when I select the <code>MenuItem</code>. I want to do the same when user selects the <code>RadioButton</code> also. Below is the code which I am using for this.</p>
  
  <pre><code>public void OnSortCommandExecuted(object menuItem)
  {
     MenuItem menu = menuItem as MenuItem;
     if (menu != null)
     {
        ((RadioButton)menu.Icon).IsChecked = !((RadioButton)menu.Icon).IsChecked;
        this.eAggregator.GetEvent&lt;ImagesSortedEvent&gt;().Publish(menu.Header.ToString());    
     }
  }
  </code></pre>