Why is the Button's Background changing?

后端 未结 2 1841
清酒与你
清酒与你 2020-12-17 04:59

I\'m a rank beginner with WPF and I don\'t even know where to look to find the answer to this question. This XAML seems very straightforward to me:



        
2条回答
  •  甜味超标
    2020-12-17 05:28

    Charlie's answer is good. I simply want to supplement with an explanation of what was going on, and a comment didn't seem the place.

    The reason why it was green for an instant and then was blue is because the default theme's ControlTemplate for Button already had an IsMouseOver Trigger to change the background.

    Then you added another in your Style. This doesn't replace the existing one because you could have multiple Triggers on the same property and value that have very different Setters and do completely different things.

    So it was trying to do both, and did the green one first.

提交回复
热议问题