title: How to bind to Selector.IsSelectionActive from a DataTemplate?
body: <p>I have the following style for a ListBoxItem defined:</p>
  
  <pre><code>    &lt;Style x:Key="detailListBoxItemStyle" TargetType="{x:Type ListBoxItem}"&gt;
      &lt;Setter Property="AutomationProperties.AutomationId" Value="{Binding Path=StringTableKey}"/&gt;
      &lt;Setter Property="Background" Value="Transparent"/&gt;
      &lt;Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/&gt;
      &lt;Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/&gt;
      &lt;Setter Property="Padding" Value="2,0,0,0"/&gt;
      &lt;Setter Property="FocusVisualStyle" Value="{x:Null}" /&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type ListBoxItem}"&gt;
                  &lt;Border x:Name="Bd" Margin="4" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true"&gt;
                      &lt;ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/&gt;
                  &lt;/Border&gt;
                  &lt;ControlTemplate.Triggers&gt;
                      &lt;Trigger Property="IsSelected" Value="true"&gt;
                          &lt;Setter Property="Background" TargetName="Bd" Value="{DynamicResource MenuItemSelectedBackgroundBrush}"/&gt;
                          &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/&gt;
                      &lt;/Trigger&gt;
                      &lt;Trigger Property="IsSelected" Value="false"&gt;
                          &lt;Setter Property="Background" TargetName="Bd" Value="{DynamicResource MenuItemUnSelectedBackgroundBrush}"/&gt;
                      &lt;/Trigger&gt;
                      &lt;!-- This is the case when a detail is selected (the master list loses focus). --&gt;
                      &lt;MultiTrigger&gt;
                          &lt;MultiTrigger.Conditions&gt;
                              &lt;Condition Property="IsSelected" Value="true"/&gt;
                              &lt;Condition Property="Selector.IsSelectionActive" Value="false"/&gt;
                          &lt;/MultiTrigger.Conditions&gt;
                          &lt;!--&lt;Setter Property="Opacity" TargetName="Bd" Value=".4"/&gt;--&gt;
                      &lt;/MultiTrigger&gt;
                      &lt;Trigger Property="IsEnabled" Value="false"&gt;
                          &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/&gt;
                      &lt;/Trigger&gt;
                  &lt;/ControlTemplate.Triggers&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>The ListBox for which this style is applied is defined as:</p>
  
  <pre><code>&lt;ListBox 
      x:Name="listBox"
      Margin="0,60,0,0"
      MaxHeight="600"
      Foreground="Transparent"
      Style="{StaticResource detailListBoxStyle}" 
      ItemContainerStyle="{StaticResource detailListBoxItemStyle}" 
      ItemsSource="{Binding Source={StaticResource detailCollectionViewSource}}" 
      ItemTemplateSelector="{StaticResource detailDataTemplateSelector}"
      TouchDown="ListBoxTouchDown"
      TouchMove="ListBoxTouchMove"
      TouchUp="ListBoxTouchUp"
      KeyDown="ListBoxKeyDown"&gt;
      &lt;ListBox.GroupStyle&gt;
          &lt;GroupStyle&gt;
              &lt;GroupStyle.HeaderTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;TextBlock Margin="0,10,0,0" FontWeight="Bold" FontSize="20" Foreground="White" Text="{Binding Path=Name}"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/GroupStyle.HeaderTemplate&gt;
          &lt;/GroupStyle&gt;
      &lt;/ListBox.GroupStyle&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>I have a DataTemplate for a ListBoxItem that can be:</p>
  
  <pre><code>&lt;DataTemplate x:Key="detailOnOffTemplate"&gt;
      &lt;Grid Height="50" Width="{StaticResource detailWidth}"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition/&gt;
              &lt;RowDefinition/&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;TextBlock x:Name="tb1" Margin="4,2,0,0" Grid.Row="0" Style="{StaticResource MenuTextStyle}" Text="{Binding DisplayName}" VerticalAlignment="Top" TextAlignment="Left"&gt;
           &lt;TextBlock.Effect&gt;
              &lt;DropShadowEffect Color="White" ShadowDepth="0" BlurRadius="7"/&gt;
          &lt;/TextBlock.Effect&gt;
          &lt;/TextBlock&gt;
      &lt;/Grid&gt;
      &lt;DataTemplate.Triggers&gt;
          &lt;DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}" Value="True"&gt;
              &lt;Setter TargetName="tb1" Property="Foreground" Value="White"/&gt;
              &lt;Setter TargetName="tb1" Property="Effect" Value="{x:Null}"/&gt;
          &lt;/DataTrigger&gt;
      &lt;/DataTemplate.Triggers&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>I need to be able to bind to "Selector.IsSelectionActive" from within my DataTemplate but nothing works. I've tried these things:</p>
  
  <pre><code>            &lt;DataTrigger Binding="{Binding Selector.IsSelectionActive, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}" Value="True"&gt;
  
              &lt;Trigger Binding="{Binding Selector.IsSelectionActive, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}" Value="True"&gt;
  
              &lt;Trigger "Selector.IsSelectionActive" Value="True"&gt;
  </code></pre>
  
  <p>Basically, I want the same trigger that is contained in the ControlTemplate in my DataTemplate:</p>
  
  <pre><code>                    &lt;MultiTrigger&gt;
                          &lt;MultiTrigger.Conditions&gt;
                              &lt;Condition Property="IsSelected" Value="true"/&gt;
                              &lt;Condition Property="Selector.IsSelectionActive" Value="false"/&gt;
                          &lt;/MultiTrigger.Conditions&gt;
                          &lt;!--&lt;Setter Property="Opacity" TargetName="Bd" Value=".4"/&gt;--&gt;
                      &lt;/MultiTrigger&gt;
  </code></pre>
  
  <p>Or, how else can I know the item "IsSelected" but does not have keyboard focus?</p>