I am using a ToggleButton in a WPF window:
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.