Files
Shrlalgo.RvKits/WPFluent/Controls/TreeListView/TreeListView.xaml

257 lines
15 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:WPFluent.Converters"
xmlns:layout="clr-namespace:WPFluent.Layout"
xmlns:controls="clr-namespace:WPFluent.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Controls/TreeView/TreeViewItem.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 x:Key="TreeExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
<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
x:Name="ChevronContainer"
Width="15"
Height="15"
Background="Transparent"
RenderTransformOrigin="0.5, 0.5">
<Grid.RenderTransform>
<RotateTransform Angle="0" />
</Grid.RenderTransform>
<controls:SymbolIcon
x:Name="ChevronIcon"
VerticalAlignment="Center"
FontSize="{StaticResource TreeViewItemChevronSize}"
Symbol="ChevronRight28" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="ChevronContainer"
Storyboard.TargetProperty="(Grid.RenderTransform).(RotateTransform.Angle)"
To="90"
Duration="0:0:0.16" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="ChevronContainer"
Storyboard.TargetProperty="(Grid.RenderTransform).(RotateTransform.Angle)"
To="0"
Duration="0:0:0.16" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DefaultTreeRowExpanderStyle" TargetType="{x:Type controls:TreeRowExpander}">
<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 VerticalAlignment="Center" ColumnDefinitions="Auto,*">
<ToggleButton
x:Name="Expander"
Grid.Column="0"
Margin="{Binding Path=Level, Converter={StaticResource TreeLevelToIndentConverter}, RelativeSource={RelativeSource AncestorType={x:Type controls:TreeListViewItem}}}"
ClickMode="Press"
IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource AncestorType={x:Type controls:TreeListViewItem}}}"
Style="{StaticResource TreeExpandCollapseToggleStyle}" />
<ContentPresenter
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
TextElement.FontSize="{TemplateBinding FontSize}"
TextElement.Foreground="{TemplateBinding Foreground}" />
</layout:Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Path=HasItems, RelativeSource={RelativeSource AncestorType={x:Type controls:TreeListViewItem}}}" Value="false">
<Setter TargetName="Expander" Property="Visibility" Value="Hidden" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type controls:TreeListViewItem}}}" Value="true">
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource DefaultTreeRowExpanderStyle}" TargetType="{x:Type controls:TreeRowExpander}" />
<Style x:Key="DefaultTreeListViewItemStyle" TargetType="{x:Type controls:TreeListViewItem}">
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<Setter Property="Foreground" Value="{DynamicResource TreeViewItemForeground}" />
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackground}" />
<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 VerticalAlignment="Center" RowDefinitions="Auto,*">
<Border
x:Name="PART_OuterBorder"
Grid.Row="0"
MinHeight="30"
Margin="0"
Padding="0"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
CornerRadius="4"
SnapsToDevicePixels="True">
<Border
x:Name="PART_InnerBorder"
Padding="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
CornerRadius="4"
SnapsToDevicePixels="True">
<controls:GridViewRowPresenter
x:Name="PART_Header"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Columns="{Binding Path=Columns, RelativeSource={RelativeSource AncestorType={x:Type controls:TreeListView}}}"
Content="{TemplateBinding Header}"
TextElement.FontSize="{TemplateBinding FontSize}" />
</Border>
</Border>
<ItemsPresenter
x:Name="ItemsHost"
Grid.Row="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</layout:Grid>
<ControlTemplate.Triggers>
<Trigger SourceName="PART_InnerBorder" Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" />
<Setter TargetName="PART_InnerBorder" Property="Background" Value="{DynamicResource ListViewItemBackgroundPointerOver}" />
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" />
<Setter TargetName="PART_InnerBorder" Property="Background" Value="{DynamicResource ButtonBackgroundPointerOver}" />
</Trigger>
<Trigger Property="IsExpanded" Value="false">
<Setter TargetName="ItemsHost" Property="Visibility" 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 TargetName="PART_Header" Property="MinWidth" Value="75" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="HasHeader" Value="false" />
<Condition Property="Height" Value="Auto" />
</MultiTrigger.Conditions>
<Setter TargetName="PART_Header" Property="MinHeight" Value="19" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource DefaultTreeListViewItemStyle}" TargetType="{x:Type controls:TreeListViewItem}" />
<Style x:Key="DefaultTreeListViewStyle" TargetType="{x:Type controls:TreeListView}">
<Setter Property="FocusVisualStyle" Value="{StaticResource DefaultControlFocusVisualStyle}" />
<Setter Property="Foreground" Value="{DynamicResource TreeViewItemForeground}" />
<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
x:Name="Bd"
Padding="0"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
<DockPanel>
<controls:GridViewHeaderRowPresenter
Margin="4"
ColumnHeaderContainerStyle="{DynamicResource UiGridViewColumnHeaderStyle}"
Columns="{TemplateBinding Columns}"
DockPanel.Dock="Top"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<ItemsPresenter />
</ScrollViewer>
</DockPanel>
</ScrollViewer>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Bd" Property="Background" 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>