Showing posts with label Button. Show all posts
Showing posts with label Button. Show all posts

2016-04-20

WPF and XAML: How to display images on the buttons correctly.

You may have already noticed that when you place an image on button in WPF, it doesn't display it well. In this post I will show you how to make your buttons look nice.



On the left is the modified button, on the right is the original one.


Introduction

The best way to do this is to create a new style that you will apply to your buttons when there are holding an image.

Of course you can put as many properties as you want in your style, create more styles and reuse them as you need.

  • In my example the button initially has an opacity of 70% and when the mouse is over it, it becomes 100%. 
  • The button in the middle is disabled, in this case its opacity is 30%.
  • When the button is clicked, it becomes smaller and gives a visual feedback.