title: WPF trigger to change parent property
body: <p>I want to override element triggers so, when clicking on a textbox, it changes the property of the parent border. </p>
  
  <p>But the parent targetname is not recognized. Here is the code sample:</p>
  
  <pre><code>   &lt;Style x:Key="customstyle" TargetType="{x:Type local:customcontrol}"&gt;
      &lt;Setter Property="Background" Value="{StaticResource DownGradientBrush}"/&gt;
      &lt;Setter Property="BorderBrush" Value="{StaticResource DownGradientBorder}"/&gt;
      &lt;Setter Property="Foreground" Value="{StaticResource TextBoxForeground}"/&gt;
      &lt;Setter Property="HorizontalAlignment" Value="Center"/&gt;
      &lt;Setter Property="VerticalAlignment" Value="Center"/&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type local:customcontrol}"&gt;
                  &lt;Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}"&gt;
                      &lt;Grid&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition/&gt;
                              &lt;RowDefinition/&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width="*"/&gt;
                              &lt;ColumnDefinition Width="15"/&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;Border Grid.Column="0" 
                                  Grid.RowSpan="2"
                                  HorizontalAlignment="Stretch"&gt;
      &lt;TextBox x:Name="TextBox"
               Grid.Column="0" 
               Grid.RowSpan="2"
               Text="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}, Path=Value}"
               Width="Auto"
               Height="Auto"&gt;
          &lt;TextBox.Style&gt;
              &lt;Style BasedOn="{StaticResource StyleTextBox}" TargetType="{x:Type TextBox}"&gt;
                  &lt;Style.Triggers&gt;
                      &lt;Trigger Property="IsFocused" Value="True"&gt;
                          &lt;Setter TargetName="Bd" 
                                  Property="Background" 
                                  Value="{StaticResource CustomGradientBorder}" /&gt;
                      &lt;/Trigger&gt;
                      &lt;Trigger Property="IsFocused" Value="True" /&gt;
                  &lt;/Style.Triggers&gt;
              &lt;/Style&gt;
          &lt;/TextBox.Style&gt;
      &lt;/TextBox&gt;
      &lt;/Border&gt;
      &lt;/Grid&gt;
      &lt;/Border&gt;
      &lt;ControlTemplate.Triggers&gt;
          &lt;Trigger Property="IsFocused" Value="True"&gt;
              &lt;Setter TargetName="Bd" Property="BorderBrush" Value="{StaticResource CustomGradientBorder}" /&gt;
          &lt;/Trigger&gt;
      &lt;/ControlTemplate.Triggers&gt;
      &lt;/ControlTemplate&gt;
      &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>