WPF Toggle Button Checked/Uchecked event with one handler

后端 未结 3 927
逝去的感伤
逝去的感伤 2021-02-18 21:27

I am using a ToggleButton in a WPF window:

 

        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-18 22:33

    You should not use Click event as some answers suggest, because it will not work when the property IsChecked is changed by code or any other event than mouse (keyboard, animation..). This is simply a bug.

    Instead you can use the same handler for both Checked and Unchecked and do action depending on IsChecked property.

    
    

提交回复
热议问题