Files
Shrlalgo.RvKits/WPFluent/Controls/TreeListView/TreeListView.xaml
ShrlAlgo 4d35cadb56 更新
2025-07-11 09:20:23 +08:00

259 lines
16 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:WPFluent.Controls"
xmlns:conv="clr-namespace:WPFluent.Converters"
xmlns:layout="clr-namespace:WPFluent.Layout"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Controls/TreeView/TreeViewItem.xaml" />
<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Resources/DefaultControlFocusVisualStyle.xaml" />
<!--<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Themes/Light.xaml" />-->
</ResourceDictionary.MergedDictionaries>
<conv:TreeLevelToIndentConverter x:Key="TreeLevelToIndentConverter" />
<FontFamily x:Key="SymbolThemeFontFamily">pack://application:,,,/WPFluent;component/Resources/Fonts/Segoe Fluent Icons.ttf#Segoe Fluent Icons</FontFamily>
<Style TargetType="{x:Type ToggleButton}" x:Key="TreeExpandCollapseToggleStyle">
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<Setter Property="Focusable" Value="False" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid
Background="Transparent"
Height="15"
RenderTransformOrigin="0.5, 0.5"
Width="15"
x:Name="ChevronContainer">
<Grid.RenderTransform>
<RotateTransform Angle="0" />
</Grid.RenderTransform>
<controls:SymbolIcon
FontSize="{StaticResource TreeViewItemChevronSize}"
Symbol="ChevronRight28"
VerticalAlignment="Center"
x:Name="ChevronIcon" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Duration="0:0:0.16"
Storyboard.TargetName="ChevronContainer"
Storyboard.TargetProperty="(Grid.RenderTransform).(RotateTransform.Angle)"
To="90" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Duration="0:0:0.16"
Storyboard.TargetName="ChevronContainer"
Storyboard.TargetProperty="(Grid.RenderTransform).(RotateTransform.Angle)"
To="0" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type controls:TreeRowExpander}" x:Key="DefaultTreeRowExpanderStyle">
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:TreeRowExpander}">
<layout:Grid ColumnDefinitions="Auto,*" VerticalAlignment="Center">
<ToggleButton
ClickMode="Press"
Grid.Column="0"
IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource AncestorType={x:Type controls:TreeListViewItem}}}"
Margin="{Binding Path=Level, Converter={StaticResource TreeLevelToIndentConverter}, RelativeSource={RelativeSource AncestorType={x:Type controls:TreeListViewItem}}}"
Style="{StaticResource TreeExpandCollapseToggleStyle}"
x:Name="Expander" />
<ContentPresenter
Content="{TemplateBinding Content}"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
TextElement.FontSize="{TemplateBinding FontSize}"
TextElement.Foreground="{TemplateBinding Foreground}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</layout:Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Path=HasItems, RelativeSource={RelativeSource AncestorType={x:Type controls:TreeListViewItem}}}" Value="false">
<Setter Property="Visibility" TargetName="Expander" Value="Hidden" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type controls:TreeListViewItem}}}" Value="true">
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource DefaultTreeRowExpanderStyle}" TargetType="{x:Type controls:TreeRowExpander}" />
<Style TargetType="{x:Type controls:TreeListViewItem}" x:Key="DefaultTreeListViewItemStyle">
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="Background" Value="{DynamicResource SubtleFillColorTransparentBrush}" />
<Setter Property="Padding" Value="4" />
<Setter Property="FontSize" Value="{StaticResource TreeViewItemFontSize}" />
<Setter Property="Border.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="IsTabStop" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="IsSelected" Value="{Binding IsSelected}" />
<Setter Property="IsExpanded" Value="{Binding IsExpanded}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:TreeListViewItem}">
<layout:Grid RowDefinitions="Auto,*" VerticalAlignment="Center">
<Border
CornerRadius="4"
Grid.Row="0"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="0"
MinHeight="30"
Padding="0"
SnapsToDevicePixels="True"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="PART_OuterBorder">
<Border
Background="{TemplateBinding Background}"
CornerRadius="4"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="True"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="PART_InnerBorder">
<controls:GridViewRowPresenter
Columns="{Binding Path=Columns, RelativeSource={RelativeSource AncestorType={x:Type controls:TreeListView}}}"
Content="{TemplateBinding Header}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
TextElement.FontSize="{TemplateBinding FontSize}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="PART_Header" />
</Border>
</Border>
<ItemsPresenter
Grid.Row="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="ItemsHost" />
</layout:Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" SourceName="PART_InnerBorder" Value="true">
<Setter Property="TextElement.Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="Background" TargetName="PART_InnerBorder" Value="{DynamicResource SubtleFillColorSecondaryBrush}" />
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter Property="TextElement.Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="Background" TargetName="PART_InnerBorder" Value="{DynamicResource ControlFillColorSecondaryBrush}" />
</Trigger>
<Trigger Property="IsExpanded" Value="false">
<Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="HasHeader" Value="false" />
<Condition Property="Width" Value="Auto" />
</MultiTrigger.Conditions>
<Setter Property="MinWidth" TargetName="PART_Header" Value="75" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="HasHeader" Value="false" />
<Condition Property="Height" Value="Auto" />
</MultiTrigger.Conditions>
<Setter Property="MinHeight" TargetName="PART_Header" Value="19" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource DefaultTreeListViewItemStyle}" TargetType="{x:Type controls:TreeListViewItem}" />
<Style TargetType="{x:Type controls:TreeListView}" x:Key="DefaultTreeListViewStyle">
<Setter Property="FocusVisualStyle" Value="{StaticResource DefaultControlFocusVisualStyle}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<!-- Default BorderBrush is from WPF instead of WPF-UI -->
<Setter Property="BorderBrush" Value="#828790" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
<Setter Property="VirtualizingPanel.IsVirtualizing" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:TreeListView}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Padding="0"
x:Name="Bd">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
<DockPanel>
<controls:GridViewHeaderRowPresenter
ColumnHeaderContainerStyle="{DynamicResource UiGridViewColumnHeaderStyle}"
Columns="{TemplateBinding Columns}"
DockPanel.Dock="Top"
Margin="4"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<ItemsPresenter />
</ScrollViewer>
</DockPanel>
</ScrollViewer>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="VirtualizingPanel.IsVirtualizing" Value="True">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource DefaultTreeListViewStyle}" TargetType="{x:Type controls:TreeListView}" />
</ResourceDictionary>