Files
ShrlAlgoToolkit/WPFluent/Controls/ListView/ListViewItem.xaml

113 lines
5.3 KiB
XML

<!--
This Source Code Form is subject to the terms of the MIT License.
If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
Copyright (C) Leszek Pomianowski and WPF UI Contributors.
All Rights Reserved.
-->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFluent.Controls">
<ControlTemplate x:Key="NullViewItemTemplate" TargetType="{x:Type controls:ListViewItem}">
<Border
x:Name="Border"
Margin="0"
Padding="0"
Background="Transparent"
BorderThickness="1"
CornerRadius="{TemplateBinding Border.CornerRadius}">
<Grid>
<ContentPresenter Margin="{TemplateBinding Padding}" />
<Rectangle
x:Name="ActiveRectangle"
Width="3"
Height="18"
Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Fill="{DynamicResource ListViewItemPillFillBrush}"
RadiusX="2"
RadiusY="2"
Visibility="Collapsed" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ListViewItemBackgroundPointerOver}" />
</MultiTrigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="ActiveRectangle" Property="Visibility" Value="Visible" />
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ListViewItemBackgroundPointerOver}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="GridViewItemTemplate" TargetType="{x:Type controls:ListViewItem}">
<Border
x:Name="Border"
Margin="0"
Padding="0"
Background="Transparent"
BorderBrush="{TemplateBinding Border.BorderBrush}"
BorderThickness="{TemplateBinding Border.BorderThickness}"
CornerRadius="{TemplateBinding Border.CornerRadius}">
<Grid>
<controls:GridViewRowPresenter
Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
Columns="{TemplateBinding GridView.ColumnCollection}"
Content="{TemplateBinding ContentControl.Content}" />
<Rectangle
x:Name="ActiveRectangle"
Width="3"
Height="18"
Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Fill="{DynamicResource ListViewItemPillFillBrush}"
RadiusX="2"
RadiusY="2"
Visibility="Collapsed" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ListViewItemBackgroundPointerOver}" />
</MultiTrigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="ActiveRectangle" Property="Visibility" Value="Visible" />
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ListViewItemBackgroundPointerOver}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="ListViewItemStyle" TargetType="{x:Type controls:ListViewItem}">
<Setter Property="Foreground" Value="{DynamicResource ListViewItemForeground}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Border.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Margin" Value="0,0,0,2" />
<Setter Property="Padding" Value="4" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=ViewState, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}" Value="Default">
<Setter Property="Template" Value="{DynamicResource NullViewItemTemplate}" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=ViewState, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}" Value="GridView">
<Setter Property="Template" Value="{DynamicResource GridViewItemTemplate}" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource ListViewItemStyle}" TargetType="{x:Type controls:ListViewItem}" />
</ResourceDictionary>