title: WPF BasedOn Styling
body: <p>Hey I'm trying to style buttons in WPF. I have a base style:</p>
  
  <pre><code>    &lt;Style x:Key="buttonStyle" TargetType="{x:Type ButtonBase}"&gt;
      &lt;Setter Property="FontWeight" Value="Bold"/&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate x:Name="ButtonBaseControlTemplate" TargetType="{x:Type ButtonBase}"&gt;
                  &lt;Grid SnapsToDevicePixels="True"&gt;
                      &lt;Border x:Name="Bd" Background="#9BC4E2" BorderBrush="Black"
                              BorderThickness="3,3,3,3" CornerRadius="7,7,7,7" Padding="5,5,5,5"&gt;
                          &lt;ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="Content"
                                        ContentSource="Content"
                                        RecognizesAccessKey="True" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
                      &lt;/Border&gt;
                  &lt;/Grid&gt;
               &lt;-- Removed triggers here --&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>But I need to use this for toggle buttons too, just to change the IsChecked background colour. But I can't access the border to set the background when I try like this:</p>
  
  <pre><code>&lt;Style TargetType="{x:Type Button}" BasedOn="{StaticResource buttonStyle}"&gt;
  &lt;/Style&gt;
  
  &lt;Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource buttonStyle}"&gt;
      &lt;Style.Triggers&gt;
          &lt;Trigger Property="IsChecked" Value="True"&gt;
              &lt;Setter Property="Background"  Value="White"/&gt; &lt;-- Need to specify target name of the border here somehow --&gt;
          &lt;/Trigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Any suggestions? ta</p>