Files
ShrlAlgoToolkit/NeoUI/Melskin/Controls/ListView.xaml

258 lines
15 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2026-01-02 17:30:30 +08:00
xmlns:assists="clr-namespace:VariaStudio.Assists"
xmlns:internal="clr-namespace:VariaStudio.Converters.Internal"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type Thumb}" x:Key="GridViewColumnHeaderGripperStyle">
<Setter Property="Background" Value="{DynamicResource DividerBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Width" Value="12" />
<Setter Property="Cursor" Value="SizeNS" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
2026-01-02 17:30:30 +08:00
<Grid Background="Transparent" Margin="6,6,-6,6">
2025-07-31 20:12:01 +08:00
<Border
2026-01-02 17:30:30 +08:00
Background="{TemplateBinding Background}"
2025-12-23 21:35:54 +08:00
HorizontalAlignment="Center"
2026-01-02 17:30:30 +08:00
Padding="{TemplateBinding Padding}"
Width="1" />
2025-07-11 09:20:23 +08:00
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
2025-08-12 23:08:54 +08:00
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Padding" Value="8,4" />
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
<Grid SnapsToDevicePixels="true">
2025-07-31 20:12:01 +08:00
<Border
2025-12-23 21:35:54 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
2026-01-02 17:30:30 +08:00
CornerRadius="4"
Margin="2"
Padding="{TemplateBinding Padding}"
x:Name="HeaderBorder">
2025-07-31 20:12:01 +08:00
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
2025-12-23 21:35:54 +08:00
RecognizesAccessKey="True"
2026-01-02 17:30:30 +08:00
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="HeaderContent" />
2025-07-11 09:20:23 +08:00
</Border>
2025-07-31 20:12:01 +08:00
<Thumb
HorizontalAlignment="Right"
2026-01-02 17:30:30 +08:00
Style="{StaticResource GridViewColumnHeaderGripperStyle}"
x:Name="PART_HeaderGripper" />
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
2026-01-02 17:30:30 +08:00
<Setter Property="Background" TargetName="HeaderBorder" Value="{DynamicResource ControlBackgroundSelectedBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsPressed" Value="true">
2026-01-02 17:30:30 +08:00
<Setter Property="Background" TargetName="HeaderBorder" Value="{DynamicResource BackgroundFloatingBrush}" />
2025-07-31 20:12:01 +08:00
<!--<Setter Property="Visibility" TargetName="PART_HeaderGripper"
2025-07-11 09:20:23 +08:00
Value="Hidden"/>-->
</Trigger>
<Trigger Property="Height" Value="Auto">
<Setter Property="MinHeight" Value="20" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Role" Value="Floating">
<Setter Property="Opacity" Value="0.4" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
<Canvas x:Name="PART_FloatingHeaderCanvas">
2025-07-31 20:12:01 +08:00
<Rectangle
2025-12-23 21:35:54 +08:00
Fill="{DynamicResource BackgroundFloatingBrush}"
2026-01-02 17:30:30 +08:00
Height="{TemplateBinding ActualHeight}"
2025-07-31 20:12:01 +08:00
Opacity="0.4"
RadiusX="2"
2026-01-02 17:30:30 +08:00
RadiusY="2"
Width="{TemplateBinding ActualWidth}" />
2025-07-11 09:20:23 +08:00
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="Role" Value="Padding">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
2025-07-31 20:12:01 +08:00
<Border
Background="{TemplateBinding Background}"
2026-01-02 17:30:30 +08:00
BorderBrush="{TemplateBinding BorderBrush}"
x:Name="HeaderBorder" />
2025-07-11 09:20:23 +08:00
<ControlTemplate.Triggers>
<Trigger Property="Height" Value="Auto">
<Setter Property="MinHeight" Value="20" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type ListView}">
2025-08-26 21:33:20 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-12 23:08:54 +08:00
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="0,4" />
<Setter Property="FontSize" Value="14" />
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="VerticalContentAlignment" Value="Center" />
2025-07-31 20:12:01 +08:00
<Setter Property="AlternationCount" Value="{Binding RelativeSource={RelativeSource Self}, Path=Items.Count}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListView}">
2025-07-31 20:12:01 +08:00
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
2026-01-02 17:30:30 +08:00
SnapsToDevicePixels="true"
x:Name="Bd">
2025-07-11 09:20:23 +08:00
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
2025-08-12 23:08:54 +08:00
<Border Background="{DynamicResource BackgroundLayoutBrush}" CornerRadius="4,4,0,0">
2025-07-31 20:12:01 +08:00
<ScrollViewer
HorizontalScrollBarVisibility="Hidden"
2026-01-02 17:30:30 +08:00
VerticalScrollBarVisibility="Disabled"
x:Name="headerScroll">
2025-07-31 20:12:01 +08:00
<GridViewHeaderRowPresenter
AllowsColumnReorder="{Binding View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}"
ColumnHeaderContainerStyle="{Binding View.ColumnHeaderContainerStyle, RelativeSource={RelativeSource TemplatedParent}}"
ColumnHeaderContextMenu="{Binding View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}"
ColumnHeaderTemplate="{Binding View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}"
ColumnHeaderToolTip="{Binding View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}"
Columns="{Binding View.Columns, RelativeSource={RelativeSource TemplatedParent}}"
2026-01-02 17:30:30 +08:00
Margin="4,0"
2025-07-31 20:12:01 +08:00
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2025-07-11 09:20:23 +08:00
</ScrollViewer>
</Border>
2025-07-31 20:12:01 +08:00
<ScrollViewer
2026-01-02 17:30:30 +08:00
Focusable="false"
2025-07-31 20:12:01 +08:00
Grid.Row="1"
Padding="{TemplateBinding Padding}"
2026-01-02 17:30:30 +08:00
assists:ControlAssist.SynchronizedScroll="{Binding ElementName=headerScroll}">
2025-07-11 09:20:23 +08:00
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</ScrollViewer>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
2026-01-02 17:30:30 +08:00
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="true" />
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" />
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Padding" Value="4" />
2025-07-31 20:12:01 +08:00
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
2025-08-26 21:33:20 +08:00
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Grid Margin="4,0">
2025-08-26 21:33:20 +08:00
<!-- 偶数行颜色 -->
2025-07-31 20:12:01 +08:00
<Border
2025-08-26 21:33:20 +08:00
Background="{DynamicResource BackgroundInterlacedBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
IsHitTestVisible="False"
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(ItemsControl.AlternationIndex), Converter={x:Static internal:InterlacedBackgroundConverter.Instance}}" />
<Border
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
2026-01-02 17:30:30 +08:00
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true"
x:Name="Bd">
2025-07-11 09:20:23 +08:00
<Grid>
<GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
2025-07-31 20:12:01 +08:00
<ContentPresenter
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-01-02 17:30:30 +08:00
Visibility="Collapsed"
x:Name="contentPresenter" />
2025-07-11 09:20:23 +08:00
</Grid>
</Border>
2025-08-26 21:33:20 +08:00
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="GridView.ColumnCollection" Value="{x:Null}">
2026-01-02 17:30:30 +08:00
<Setter Property="Visibility" TargetName="contentPresenter" Value="Visible" />
2025-07-11 09:20:23 +08:00
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
2026-01-02 17:30:30 +08:00
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBackgroundSelectedBrush}" />
2025-07-11 09:20:23 +08:00
</MultiTrigger>
2025-07-31 20:12:01 +08:00
<!-- 选中对象无焦点 -->
2025-07-11 09:20:23 +08:00
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Selector.IsSelectionActive" Value="False" />
<Condition Property="IsSelected" Value="True" />
</MultiTrigger.Conditions>
2026-01-02 17:30:30 +08:00
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource BackgroundFloatingBrush}" />
2025-07-11 09:20:23 +08:00
</MultiTrigger>
2025-07-31 20:12:01 +08:00
<!-- 选中对象有焦点 -->
2025-07-11 09:20:23 +08:00
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Selector.IsSelectionActive" Value="True" />
<Condition Property="IsSelected" Value="True" />
</MultiTrigger.Conditions>
2026-01-02 17:30:30 +08:00
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource TextAccentBrush}" />
2025-07-11 09:20:23 +08:00
</MultiTrigger>
<Trigger Property="IsEnabled" Value="False">
2026-01-02 17:30:30 +08:00
<Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource TextDisabledBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>