342 lines
19 KiB
XML
342 lines
19 KiB
XML
<ResourceDictionary
|
|
x:Class="WPFluent.Controls.Dictionary.TreeViewItem"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:controls="clr-namespace:WPFluent.Controls"
|
|
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
<system:Double x:Key="TreeViewItemChevronSize">10</system:Double>
|
|
<system:Double x:Key="TreeViewItemFontSize">14</system:Double>
|
|
|
|
<Style TargetType="{x:Type ToggleButton}" x:Key="ExpandCollapseToggleButtonStyle">
|
|
<!-- Universal WPF UI focus -->
|
|
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
|
|
<!-- Universal WPF UI focus -->
|
|
<Setter Property="Focusable" Value="False" />
|
|
<Setter Property="OverridesDefaultStyle" Value="True" />
|
|
<Setter Property="SnapsToDevicePixels" Value="True" />
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="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 TreeViewItem}" x:Key="DefaultTreeViewItemStyle">
|
|
<!-- Universal WPF UI focus -->
|
|
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
|
|
<!-- Universal WPF UI focus -->
|
|
<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="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type TreeViewItem}">
|
|
<Grid Background="{TemplateBinding Background}">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
<Border
|
|
CornerRadius="{TemplateBinding Border.CornerRadius}"
|
|
Grid.Row="0"
|
|
x:Name="Border">
|
|
<Grid>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition MinWidth="19" Width="Auto" />
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="*" />
|
|
</Grid.ColumnDefinitions>
|
|
<Rectangle
|
|
Fill="{DynamicResource SystemFillColorAttentionBrush}"
|
|
Grid.Column="0"
|
|
Height="16"
|
|
HorizontalAlignment="Left"
|
|
Margin="0,0,0,0"
|
|
RadiusX="2"
|
|
RadiusY="2"
|
|
VerticalAlignment="Center"
|
|
Visibility="Collapsed"
|
|
Width="3"
|
|
x:Name="ActiveRectangle" />
|
|
<ToggleButton
|
|
ClickMode="Press"
|
|
Grid.Column="0"
|
|
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
|
|
Margin="8,0"
|
|
Style="{StaticResource ExpandCollapseToggleButtonStyle}"
|
|
x:Name="Expander" />
|
|
<ContentPresenter
|
|
ContentSource="Header"
|
|
Grid.Column="1"
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
Margin="{TemplateBinding Padding}"
|
|
TextElement.FontSize="{TemplateBinding FontSize}"
|
|
x:Name="PART_Header" />
|
|
</Grid>
|
|
</Border>
|
|
<Grid Grid.Row="1">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition MinWidth="19" Width="Auto" />
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="*" />
|
|
</Grid.ColumnDefinitions>
|
|
<ItemsPresenter
|
|
Grid.Column="1"
|
|
Grid.ColumnSpan="2"
|
|
Visibility="Collapsed"
|
|
x:Name="ItemsHost" />
|
|
</Grid>
|
|
</Grid>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="HasItems" Value="False">
|
|
<Setter Property="Visibility" TargetName="Expander" Value="Hidden" />
|
|
</Trigger>
|
|
<Trigger Property="IsExpanded" Value="True">
|
|
<Setter Property="Visibility" TargetName="ItemsHost" Value="Visible" />
|
|
</Trigger>
|
|
<Trigger Property="IsMouseOver" Value="True">
|
|
<Setter Property="Background" TargetName="Border" Value="{DynamicResource SubtleFillColorSecondaryBrush}" />
|
|
</Trigger>
|
|
<Trigger Property="IsSelected" Value="True">
|
|
<Setter Property="Background" TargetName="Border" Value="{DynamicResource SubtleFillColorSecondaryBrush}" />
|
|
<Setter Property="Visibility" TargetName="ActiveRectangle" Value="Visible" />
|
|
</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>
|
|
<EventSetter Event="RequestBringIntoView" Handler="OnRequestBringIntoView" />
|
|
<Style.Triggers>
|
|
<Trigger Property="VirtualizingPanel.IsVirtualizing" Value="True">
|
|
<Setter Property="ItemsPanel">
|
|
<Setter.Value>
|
|
<ItemsPanelTemplate>
|
|
<VirtualizingStackPanel />
|
|
</ItemsPanelTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Trigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
|
|
<Style TargetType="{x:Type controls:TreeViewItem}" x:Key="DefaultUiTreeViewItemStyle">
|
|
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
|
|
<Setter Property="Background" Value="{DynamicResource SubtleFillColorTransparentBrush}" />
|
|
<Setter Property="Padding" Value="4" />
|
|
<Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}" />
|
|
<Setter Property="OverridesDefaultStyle" Value="True" />
|
|
<Setter Property="SnapsToDevicePixels" Value="True" />
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type controls:TreeViewItem}">
|
|
<Grid Background="{TemplateBinding Background}">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="*" />
|
|
</Grid.ColumnDefinitions>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition />
|
|
</Grid.RowDefinitions>
|
|
<ToggleButton
|
|
ClickMode="Press"
|
|
Grid.Column="0"
|
|
Grid.Row="0"
|
|
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
|
|
Style="{StaticResource ExpandCollapseToggleButtonStyle}"
|
|
x:Name="Expander" />
|
|
<Border
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
Grid.Column="1"
|
|
Grid.Row="0"
|
|
Padding="{TemplateBinding Padding}"
|
|
x:Name="Bd">
|
|
<Border.Background>
|
|
<SolidColorBrush Color="{DynamicResource SystemAccentColor}" Opacity="0.0" />
|
|
</Border.Background>
|
|
<Grid>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="*" />
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<ContentPresenter
|
|
Content="{TemplateBinding Icon}"
|
|
Grid.Column="0"
|
|
Margin="0,0,8,0"
|
|
TextElement.Foreground="{TemplateBinding Foreground}"
|
|
x:Name="SymbolIcon" />
|
|
|
|
<ContentPresenter
|
|
ContentSource="Header"
|
|
Grid.Column="1"
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
x:Name="PART_Header" />
|
|
</Grid>
|
|
</Border>
|
|
<ItemsPresenter
|
|
Grid.Column="1"
|
|
Grid.ColumnSpan="2"
|
|
Grid.Row="1"
|
|
Visibility="Collapsed"
|
|
x:Name="ItemsHost" />
|
|
<VisualStateManager.VisualStateGroups>
|
|
<!--
|
|
<VisualStateGroup Name="CommonStates">
|
|
<VisualStateGroup.Transitions>
|
|
<VisualTransition GeneratedDuration="0:0:0.16" />
|
|
</VisualStateGroup.Transitions>
|
|
<VisualState Name="Normal" />
|
|
<VisualState Name="MouseOver">
|
|
<Storyboard>
|
|
<DoubleAnimation
|
|
Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Opacity)"
|
|
From="0.0"
|
|
To="0.5"
|
|
Duration="0:0:.16" />
|
|
</Storyboard>
|
|
</VisualState>
|
|
<VisualState Name="Pressed" />
|
|
<VisualState Name="Disabled" />
|
|
</VisualStateGroup>
|
|
-->
|
|
<VisualStateGroup x:Name="SelectionStates">
|
|
<VisualState x:Name="Selected">
|
|
<Storyboard>
|
|
<DoubleAnimation
|
|
Duration="0:0:.16"
|
|
From="0.0"
|
|
Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Opacity)"
|
|
To="1.0" />
|
|
</Storyboard>
|
|
</VisualState>
|
|
<VisualState x:Name="Unselected" />
|
|
<VisualState x:Name="SelectedInactive">
|
|
<Storyboard>
|
|
<DoubleAnimation
|
|
Duration="0:0:.16"
|
|
From="0.0"
|
|
Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Opacity)"
|
|
To="1.0" />
|
|
</Storyboard>
|
|
</VisualState>
|
|
</VisualStateGroup>
|
|
<VisualStateGroup x:Name="ExpansionStates">
|
|
<VisualState x:Name="Expanded">
|
|
<Storyboard>
|
|
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemsHost" Storyboard.TargetProperty="(UIElement.Visibility)">
|
|
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
|
|
</ObjectAnimationUsingKeyFrames>
|
|
</Storyboard>
|
|
</VisualState>
|
|
<VisualState x:Name="Collapsed" />
|
|
</VisualStateGroup>
|
|
</VisualStateManager.VisualStateGroups>
|
|
</Grid>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="Icon" Value="{x:Null}">
|
|
<Setter Property="Visibility" TargetName="SymbolIcon" Value="Collapsed" />
|
|
<Setter Property="Margin" TargetName="SymbolIcon" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="HasItems" Value="False">
|
|
<Setter Property="Visibility" TargetName="Expander" Value="Hidden" />
|
|
</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.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 DefaultTreeViewItemStyle}" TargetType="{x:Type TreeViewItem}" />
|
|
<Style BasedOn="{StaticResource DefaultUiTreeViewItemStyle}" TargetType="{x:Type controls:TreeViewItem}" />
|
|
|
|
</ResourceDictionary>
|