title: How can I check if mouse button is left or right in wpf C#?
body: <p>I'm trying this code actually I have created only one Eventhandler that is on <code>Click="button_Click"</code>.</p>
  
  <p>XAML:   </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Window x:Class="WPFAPP.Window1" 
      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:local="clr-namespace:WPFAPP"
      mc:Ignorable="d"
      Title="Window1" Height="447.625" Width="562"&gt;
  
      &lt;Grid&gt;
          &lt;Button x:Name="btn1" Content="Button1" Click="button_Click" HorizontalAlignment="Left" Margin="26,22,0,0" VerticalAlignment="Top" Width="75"/&gt;
          &lt;Button x:Name="btn2" Content="Button2" Click="button_Click" HorizontalAlignment="Left" Margin="26,61,0,0" VerticalAlignment="Top" Width="75"/&gt;
          &lt;Button x:Name="btn3" Content="Button3" Click="button_Click" HorizontalAlignment="Left" Margin="26,100,0,0" VerticalAlignment="Top" Width="75"/&gt;
          &lt;Button x:Name="btn4" Content="Button4" Click="button_Click" HorizontalAlignment="Left" Margin="26,137,0,0" VerticalAlignment="Top" Width="75"/&gt;
          &lt;Button x:Name="btn5" Content="Button5" Click="button_Click" HorizontalAlignment="Left" Margin="26,174,0,0" VerticalAlignment="Top" Width="75"/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt; 
  </code></pre>
  
  <p>Code Behind C#:</p>
  
  <pre><code>private void button_Click(object sender, RoutedEventArgs e)
  {
      Button button = (Button)sender;
      if(e.Equals(Mouse.RightButton))
      {
          button.ClearValue(Button.BackgroundProperty);
          button.Background = Brushes.Green;
      } 
  } 
  </code></pre>