Сохранить фокус эффект после нажатия и последующих фокусах на другие элементы в двух listview WPF

Есть два ListView, и для них написан template, нужно сохранить focus эффект последнего выбранного элемента у каждого ListView

введите сюда описание изображения

xaml:

<Window.Resources>
    <ControlTemplate x:Key="LeftButtons" TargetType="Button">
        <Grid Name="Btn" Height="35">
            <Border>
                <Grid>
                    <Label Content="{TemplateBinding Content}" 
                       Background="Transparent"
                       FontSize="14"
                       VerticalAlignment="Center">
                        <Label.Style>
                            <Style TargetType="Label">
                                <Setter Property="Margin" Value="10 0 0 0"/>
                                <Setter Property="Foreground" Value="#5E5E5E"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=Btn}"
                                             Value="true">
                                        <Setter Property="Foreground" Value="#fff"/>
                                    </DataTrigger>
                                    
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource
                                    Mode=FindAncestor,
                                    AncestorType={x:Type Button}},
                                    Path=IsFocused}"
                                             Value="true">
                                        <Setter Property="Foreground" Value="#fff"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Label.Style>
                    </Label>

                    <Border Name="BorderDepth" Background="Transparent" CornerRadius="5" BorderBrush="#fff">
                        <Border.Style>
                            <Style TargetType="Border">
                                <Setter Property="BorderThickness" Value="0"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=BorderDepth}"
                                             Value="true">
                                        <Setter Property="BorderThickness" Value=".5"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource
                                    Mode=FindAncestor,
                                    AncestorType={x:Type Button}},
                                    Path=IsFocused}"
                                             Value="true">
                                        <Setter Property="BorderThickness" Value=".5"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Border.Style>
                        <Border.Effect>
                            <DropShadowEffect ShadowDepth="0" BlurRadius="4" Color="#fff"/>
                        </Border.Effect>
                    </Border>

                </Grid>
            </Border>
        </Grid>
    </ControlTemplate>
</Window.Resources>

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>

    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition/>
    </Grid.RowDefinitions>

    <ListView Grid.Column="0">
        <ListViewItem Content="123"/>
        <ListViewItem Content="123"/>
        <ListViewItem Content="123"/>
    </ListView>

    <ListView Grid.Column="1">
        <ListViewItem Content="123"/>
        <ListViewItem Content="123"/>
        <ListViewItem Content="123"/>
    </ListView>

    <ListView Grid.Column="0" Grid.Row="1" Background="Black">
        <Button Content="123"  Template="{StaticResource LeftButtons}"/>
        <Button Content="123"  Template="{StaticResource LeftButtons}"/>
        <Button Content="123"  Template="{StaticResource LeftButtons}"/>
        <Button Content="123"  Template="{StaticResource LeftButtons}"/>

        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                            <Border x:Name="Bd">
                                <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                            
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ListView.ItemContainerStyle>

    </ListView>

    <ListView Grid.Column="1" Grid.Row="1" Background="Black">

        <Button Content="333" Template="{StaticResource LeftButtons}"/>
        <Button Content="333" Template="{StaticResource LeftButtons}"/>
        <Button Content="333" Template="{StaticResource LeftButtons}"/>

        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                            <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
                                <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                            <ControlTemplate.Triggers>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsMouseOver" Value="True"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Background" TargetName="Bd" Value="Transparent"/>
                                    <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
                                </MultiTrigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="Selector.IsSelectionActive" Value="False"/>
                                        <Condition Property="IsSelected" Value="True"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Background" TargetName="Bd" Value="Transparent"/>
                                    <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
                                </MultiTrigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="Selector.IsSelectionActive" Value="True"/>
                                        <Condition Property="IsSelected" Value="True"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Background" TargetName="Bd" Value="Transparent"/>
                                    <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
                                </MultiTrigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ListView.ItemContainerStyle>
    </ListView>

</Grid>

Ответы (0 шт):