Background does not change of button C# WPF

后端 未结 4 1335
一个人的身影
一个人的身影 2020-12-18 09:25

I am trying to change style on mouseover.

My Code is:

4条回答
  •  死守一世寂寞
    2020-12-18 09:51

    Edit: As Rohit pointed out in the comments,

    This won't work on Windows 8 because of some changes in PresentationFramework where default template of button is declared. ... In Windows 7 default template of button doesn't have that ControlTemplate trigger. That's why your posted code works fine on Windows7 but it won't work on Windows 8 and higher.


    Rohit's answer about DependencyProperty Precedence being the cause is correct, but there's a much simpler way of fixing it than overwriting the Button's Template.

    If you review the DependencyProperty Precedence List, you'll notice that properties set in the have a higher precedence than Triggered properties, which is why your button will always use the background you have defined in your

提交回复
热议问题