Experts, tell me please, how can I prohibit the animation of clicking ToggleButton? If the button is pressed, then the other automatically changes the style to not pressed, but if I press the button that is pressed - it is squeezed out - how to disable this "spin"?

  • As I understand it, you need to make sure that only one of the two ToogleButton can be active? - Lightness
  • Yes, at the same time, if you repeatedly click on the active one, it will not change, and it will also remain active - Elizaveta

1 answer 1

You can simply handle the Click event for each ToogleButton .

  <ToggleButton Name="toogle1" Click="Toogle1_OnClick"></ToggleButton> <ToggleButton Name="toogle2" Click="Toogle2_OnClick"></ToggleButton> 

Handlers:

  private void Toogle1_OnClick(object sender, RoutedEventArgs e) { var button = (ToggleButton)e.OriginalSource; if ((bool)button.IsChecked) { button.IsEnabled = false; toogle2.IsChecked = false; toogle2.IsEnabled = true; } } private void Toogle2_OnClick(object sender, RoutedEventArgs e) { var button = (ToggleButton)e.OriginalSource; if ((bool)button.IsChecked) { button.IsEnabled = false; toogle1.IsChecked = false; toogle1.IsEnabled = true; } } 
  • Thanks helped! - Elizabeth
  • @ Elizabeth, Please! - Lightness