title: Binding styled ListBoxItem with RelayCommand
body: <ul>
  <li>As seen from below DataTemplate, I have created listview of buttons.    I have specified Command and CommandParameter for this button. But    when these buttons are CanExecute and Execute methods are not fired.    Now if, I place a single button on the user control and bind the    command, the event fires. Why does this happen ?</li>
  </ul>
  
  <blockquote>
  <pre><code>       &lt;ListView ItemContainerStyle="{StaticResource AlphabetsContainerStyle}" 
                ItemsSource="{Binding Alphabets}"/&gt;
              &lt;Button Command="{Binding Path=FilterCommand}" CommandParameter="A"/&gt;   &lt;!-- Works --&gt;
  
  
              &lt;!-- Code in the Resource Dictionary File --&gt;
  
              &lt;DataTemplate x:Key="AlphabetsTemplate"&gt;
                      &lt;Border&gt;            
                          &lt;Button Content="{Binding}"  
                                  Command="{Binding Path=FilterCommand}"
                                  CommandParameter="A"/&gt;                   &lt;!-- Doesn't Work --&gt;
                      &lt;/Border&gt;
              &lt;/DataTemplate&gt;
  
              &lt;Style TargetType="{x:Type ListBoxItem}" x:Key="AlphabetsContainerStyle"&gt;
                  &lt;Setter Property="ContentTemplate" Value="{StaticResource AlphabetsTemplate}"/&gt;
              &lt;/Style&gt;
  </code></pre>
  </blockquote>
  
  <p>**<em>I have removed other setter properties and resources for keeping the codeview clean.</em></p>
  
  <ul>
  <li>Secondly, how can I replace button with label and attach the ICommand    directly to the ListBoxItem?</li>
  </ul>
  
  <blockquote>
  <pre><code> &lt;!-- Replacing Button with Label --&gt;
  </code></pre>
  </blockquote>
  
  <pre><code>    &lt;DataTemplate x:Key="AlphabetsTemplate"&gt;
              &lt;Border&gt;            
                  &lt;Label Content="{Binding}"         &lt;!-- Label Doesnt have Command Property --&gt;
              &lt;/Border&gt;
      &lt;/DataTemplate&gt;
  
   &lt;!-- How can I  set Command directly to ListBoxItem ?--&gt;
      &lt;Style TargetType="{x:Type ListBoxItem}" x:Key="AlphabetsContainerStyle"&gt;
          &lt;Setter Property="ContentTemplate" Value="{StaticResource AlphabetsTemplate}"/&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>Thank you in advance. :)</p>
  
  <p>Regards,</p>