title: Style WPF radio button as toggle button with correct IsEnabled behaviour
body: <p>I need to style some grouped radio buttons as toggle buttons. To do this I've applied the following style to the radio buttons:</p>
  
  <pre><code>Style="{StaticResource {x:Type ToggleButton}}"
  </code></pre>
  
  <p>This gives me the style I'd like, but I noticed an annoying side effect. I need to be able to change the selected button whilst the controls are disabled. This works as expected with normal radio buttons. However, with the toggle button styled buttons it no longer shows one of the buttons as being selected.</p>
  
  <p>In the following demo if you repeatedly click the 'Toggle enabled' button you can see that the selected button is still highlighted when it is re-enabled. However, if you change the selected button while they're disabled and then re-enable (click 'Toggle enabled', 'Change value', 'Toggle enabled'), neither of the buttons are highlighted. </p>
  
  <p>What I'm trying to achieve:</p>
  
  <ol>
  <li>Keep as close as possible to the style of the ToggleButton.</li>
  <li>When a checked button is disabled keep the blue background but with opacity.</li>
  <li>Have the standard ToggleButton style when the button is re-enabled regardless of whether the value has changed.</li>
  </ol>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window x:Class="ToggleButtonDemo.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          xmlns:local="clr-namespace:ToggleButtonDemo"
          mc:Ignorable="d"
          Title="MainWindow" Height="200" Width="200"
          Name="demoWindow"
          DataContext="{Binding ElementName=demoWindow}"&gt;
      &lt;StackPanel&gt;
          &lt;GroupBox Header="Radio" IsEnabled="{Binding Enable}"&gt;
              &lt;StackPanel Orientation="Horizontal"&gt;
                  &lt;RadioButton Name="radio1" Content="One" GroupName="RadioGroup" IsChecked="True"/&gt;
                  &lt;RadioButton Name="radio2" Content="Two" GroupName="RadioGroup"/&gt;
              &lt;/StackPanel&gt;
          &lt;/GroupBox&gt;
          &lt;GroupBox Header="Toggle" IsEnabled="{Binding Enable}"&gt;
              &lt;StackPanel Orientation="Horizontal"&gt;
                  &lt;RadioButton Name="toggle1" Content="One" GroupName="ToggleGroup" Style="{StaticResource {x:Type ToggleButton}}" IsChecked="True"/&gt;
                  &lt;RadioButton Name="toggle2" Content="Two" GroupName="ToggleGroup" Style="{StaticResource {x:Type ToggleButton}}"/&gt;
              &lt;/StackPanel&gt;
          &lt;/GroupBox&gt;
          &lt;Button Name="toggle" Content="Toggle enabled" Click="toggle_Click"/&gt;
          &lt;Button Name="changeValue" Content="Change value" Click="changeValue_Click"/&gt;
      &lt;/StackPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>Code behind:</p>
  
  <pre><code>using System.ComponentModel;
  using System.Windows;
  
  namespace ToggleButtonDemo
  {
      /// &lt;summary&gt;
      /// Interaction logic for MainWindow.xaml
      /// &lt;/summary&gt;
      public partial class MainWindow : Window, INotifyPropertyChanged
      {
  
          private bool mEnable = true;
  
          public bool Enable
          {
              get
              {
                  return mEnable;
              }
              set
              {
                  mEnable = value;
                  OnPropertyChanged(nameof(Enable));
              }
          }
  
          public MainWindow()
          {
              InitializeComponent();
          }
  
          public event PropertyChangedEventHandler PropertyChanged;
  
          public virtual void OnPropertyChanged(string propertyName)
          {
              PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
          }
  
          private void toggle_Click(object sender, RoutedEventArgs e)
          {
              Enable = !Enable;
          }
  
          private void changeValue_Click(object sender, RoutedEventArgs e)
          {
              if (radio1.IsChecked == true)
              {
                  radio2.IsChecked = true;
              }
              else if (radio2.IsChecked == true)
              {
                  radio1.IsChecked = true;
              }
  
              if (toggle1.IsChecked == true)
              {
                  toggle2.IsChecked = true;
              }
              else if (toggle2.IsChecked == true)
              {
                  toggle1.IsChecked = true;
              }
          }
      }
  }
  </code></pre>