title: How to create a button Image in WPF
body: <p>I have a button that I am trying to use with certain images. Xaml for the button is below.</p>
  
  <pre><code>    &lt;Button Name="Button1" Grid.Row="1" Grid.Column="1" Background="Transparent" BorderBrush="Transparent" Click="Button1_Click" MouseEnter="Button1_MouseEnter" MouseLeave="Button1_MouseLeave"&gt;            
              &lt;Image Name="Button1_Image" Source="/Assets/Button1Passive.png"/&gt;            
      &lt;/Button&gt;
  </code></pre>
  
  <p>The code behind:</p>
  
  <pre><code>private void Button1_Click(object sender, RoutedEventArgs e)
      {
          if (!Button1Active)
          {
              BitmapImage Image1 = new BitmapImage(new Uri("/Assets/Button1Selected.png", UriKind.Relative));
              Button1_Image.Source = Image1;
              Button1Active = true;
          }
          else
          {
              BitmapImage Image1 = new BitmapImage(new Uri("/Assets/Button1Passive.png", UriKind.Relative));
              Button1_Image.Source = Image1;
              Button1Active = false;
          }
      }
  
      private void Button1_MouseEnter(object sender, MouseEventArgs e)
      {
          if (!Button1Active)
          {
              BitmapImage Image1 = new BitmapImage(new Uri("/Assets/Button1RolledOver.png", UriKind.Relative));
              Button1_Image.Source = Image1;
  
  
          }
      }
  
      private void Button1_MouseLeave(object sender, MouseEventArgs e)
      {
          if (!Button1Active)
          {
              BitmapImage Image1 = new BitmapImage(new Uri("/Assets/Button1Passive.png", UriKind.Relative));
              Button1_Image.Source = Image1;
          }
      }
  </code></pre>
  
  <p>The problem that I am having is that the image does not take up the entire button and there is a blue box that is around the image when the mouse rolls over it.</p>
  
  <p><img src="https://i.imgur.com/UehS6N2.png" alt="WPF Box"></p>
  
  <p>I have looked to see if there is another solution and everything that I could find did not allow me to change the image programmatically.</p>
  
  <p>Thanks in advance.</p>