WPF change button Image when mouse hover

前端 未结 2 1846
半阙折子戏
半阙折子戏 2021-01-28 07:51

I am new to wpf, and I am trying to change a button\'s image on mouse hovering with no success (using some methods that mentioned in some answers).

The code is:

2条回答
  •  后悔当初
    2021-01-28 08:31

    please try to set the next style as a style for your button:

      
    

    A small explanation: Each time you will over your button with the mouse, the content image will be switched.

    Update #1 - Style with animation when pressed

    
    

    Explanation for Update #1: Here the button control is completely re-templated, you can define your own content as you need, and in addition it is animated when pressed(like a regular button). The animation is a scaling of the button with some parameters.

    You can see how it looks like:

    Regards.

提交回复
热议问题