I am trying to create a button which has 3 images: a Normal image, a Pressed image and a Disabled image (I will use these for creating up/down arrow buttons).
I believe the correct approach would be to derive from Button
and use a Template
and set triggers to change the image. I have 3 dependency properties, one for each image.
The images would be .png and have transparent backgrounds (as they are not rectangular).
I am looking for something like CBitmapButton
in MFC.
The simple way in WPF:
Create a button image with Photoshop or other programs.
Place it on your window and use the
MouseEnter
andMouseLeave
events.You won't need dependency properties because you are inheriting from
Button
. You already have theIsPressed
andIsEnabled
properties. In fact, this is all you need:With your UserControl code-behind file:
Simply try this code
I have provided an alternative to this solution, its not quite as light weight but it offers much greater re-usability.
WPF TriState Image Button