350 lines
19 KiB
Plaintext
350 lines
19 KiB
Plaintext
|
|
<!--
|
||
|
|
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
|
||
|
|
x:Class="WPFluent.Controls.Dictionary.TreeViewItem"
|
||
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||
|
|
xmlns:controls="clr-namespace:WPFluent.Controls"
|
||
|
|
xmlns:system="clr-namespace:System;assembly=System.Runtime">
|
||
|
|
|
||
|
|
<system:Double x:Key="TreeViewItemChevronSize">10</system:Double>
|
||
|
|
<system:Double x:Key="TreeViewItemFontSize">14</system:Double>
|
||
|
|
|
||
|
|
<Style x:Key="ExpandCollapseToggleButtonStyle" TargetType="{x:Type ToggleButton}">
|
||
|
|
<!-- 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
|
||
|
|
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="DefaultTreeViewItemStyle" TargetType="{x:Type TreeViewItem}">
|
||
|
|
<!-- Universal WPF UI focus -->
|
||
|
|
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
|
||
|
|
<!-- Universal WPF UI focus -->
|
||
|
|
<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="Template">
|
||
|
|
<Setter.Value>
|
||
|
|
<ControlTemplate TargetType="{x:Type TreeViewItem}">
|
||
|
|
<Grid Background="{TemplateBinding Background}">
|
||
|
|
<Grid.RowDefinitions>
|
||
|
|
<RowDefinition Height="Auto" />
|
||
|
|
<RowDefinition Height="Auto" />
|
||
|
|
</Grid.RowDefinitions>
|
||
|
|
<Border
|
||
|
|
x:Name="Border"
|
||
|
|
Grid.Row="0"
|
||
|
|
CornerRadius="{TemplateBinding Border.CornerRadius}">
|
||
|
|
<Grid>
|
||
|
|
<Grid.ColumnDefinitions>
|
||
|
|
<ColumnDefinition Width="Auto" MinWidth="19" />
|
||
|
|
<ColumnDefinition Width="Auto" />
|
||
|
|
<ColumnDefinition Width="*" />
|
||
|
|
</Grid.ColumnDefinitions>
|
||
|
|
<Rectangle
|
||
|
|
x:Name="ActiveRectangle"
|
||
|
|
Grid.Column="0"
|
||
|
|
Width="3"
|
||
|
|
Height="16"
|
||
|
|
Margin="0,0,0,0"
|
||
|
|
HorizontalAlignment="Left"
|
||
|
|
VerticalAlignment="Center"
|
||
|
|
Fill="{DynamicResource TreeViewItemSelectionIndicatorForeground}"
|
||
|
|
RadiusX="2"
|
||
|
|
RadiusY="2"
|
||
|
|
Visibility="Collapsed" />
|
||
|
|
<ToggleButton
|
||
|
|
x:Name="Expander"
|
||
|
|
Grid.Column="0"
|
||
|
|
Margin="8,0"
|
||
|
|
ClickMode="Press"
|
||
|
|
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
|
||
|
|
Style="{StaticResource ExpandCollapseToggleButtonStyle}" />
|
||
|
|
<ContentPresenter
|
||
|
|
x:Name="PART_Header"
|
||
|
|
Grid.Column="1"
|
||
|
|
Margin="{TemplateBinding Padding}"
|
||
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||
|
|
ContentSource="Header"
|
||
|
|
TextElement.FontSize="{TemplateBinding FontSize}" />
|
||
|
|
</Grid>
|
||
|
|
</Border>
|
||
|
|
<Grid Grid.Row="1">
|
||
|
|
<Grid.ColumnDefinitions>
|
||
|
|
<ColumnDefinition Width="Auto" MinWidth="19" />
|
||
|
|
<ColumnDefinition Width="Auto" />
|
||
|
|
<ColumnDefinition Width="*" />
|
||
|
|
</Grid.ColumnDefinitions>
|
||
|
|
<ItemsPresenter
|
||
|
|
x:Name="ItemsHost"
|
||
|
|
Grid.Column="1"
|
||
|
|
Grid.ColumnSpan="2"
|
||
|
|
Visibility="Collapsed" />
|
||
|
|
</Grid>
|
||
|
|
</Grid>
|
||
|
|
<ControlTemplate.Triggers>
|
||
|
|
<Trigger Property="HasItems" Value="False">
|
||
|
|
<Setter TargetName="Expander" Property="Visibility" Value="Hidden" />
|
||
|
|
</Trigger>
|
||
|
|
<Trigger Property="IsExpanded" Value="True">
|
||
|
|
<Setter TargetName="ItemsHost" Property="Visibility" Value="Visible" />
|
||
|
|
</Trigger>
|
||
|
|
<Trigger Property="IsMouseOver" Value="True">
|
||
|
|
<Setter TargetName="Border" Property="Background" Value="{DynamicResource TreeViewItemBackgroundPointerOver}" />
|
||
|
|
</Trigger>
|
||
|
|
<Trigger Property="IsSelected" Value="True">
|
||
|
|
<Setter TargetName="Border" Property="Background" Value="{DynamicResource TreeViewItemBackgroundSelected}" />
|
||
|
|
<Setter TargetName="ActiveRectangle" Property="Visibility" Value="Visible" />
|
||
|
|
</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>
|
||
|
|
<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 x:Key="DefaultUiTreeViewItemStyle" TargetType="{x:Type controls:TreeViewItem}">
|
||
|
|
<Setter Property="Foreground" Value="{DynamicResource TreeViewItemForeground}" />
|
||
|
|
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackground}" />
|
||
|
|
<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
|
||
|
|
x:Name="Expander"
|
||
|
|
Grid.Row="0"
|
||
|
|
Grid.Column="0"
|
||
|
|
ClickMode="Press"
|
||
|
|
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
|
||
|
|
Style="{StaticResource ExpandCollapseToggleButtonStyle}" />
|
||
|
|
<Border
|
||
|
|
x:Name="Bd"
|
||
|
|
Grid.Row="0"
|
||
|
|
Grid.Column="1"
|
||
|
|
Padding="{TemplateBinding Padding}"
|
||
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||
|
|
BorderThickness="{TemplateBinding BorderThickness}">
|
||
|
|
<Border.Background>
|
||
|
|
<SolidColorBrush Opacity="0.0" Color="{DynamicResource SystemAccentColor}" />
|
||
|
|
</Border.Background>
|
||
|
|
<Grid>
|
||
|
|
<Grid.ColumnDefinitions>
|
||
|
|
<ColumnDefinition Width="Auto" />
|
||
|
|
<ColumnDefinition Width="*" />
|
||
|
|
</Grid.ColumnDefinitions>
|
||
|
|
|
||
|
|
<ContentPresenter
|
||
|
|
x:Name="SymbolIcon"
|
||
|
|
Grid.Column="0"
|
||
|
|
Margin="0,0,8,0"
|
||
|
|
Content="{TemplateBinding Icon}"
|
||
|
|
TextElement.Foreground="{TemplateBinding Foreground}" />
|
||
|
|
|
||
|
|
<ContentPresenter
|
||
|
|
x:Name="PART_Header"
|
||
|
|
Grid.Column="1"
|
||
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||
|
|
ContentSource="Header" />
|
||
|
|
</Grid>
|
||
|
|
</Border>
|
||
|
|
<ItemsPresenter
|
||
|
|
x:Name="ItemsHost"
|
||
|
|
Grid.Row="1"
|
||
|
|
Grid.Column="1"
|
||
|
|
Grid.ColumnSpan="2"
|
||
|
|
Visibility="Collapsed" />
|
||
|
|
<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
|
||
|
|
Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Opacity)"
|
||
|
|
From="0.0"
|
||
|
|
To="1.0"
|
||
|
|
Duration="0:0:.16" />
|
||
|
|
</Storyboard>
|
||
|
|
</VisualState>
|
||
|
|
<VisualState x:Name="Unselected" />
|
||
|
|
<VisualState x:Name="SelectedInactive">
|
||
|
|
<Storyboard>
|
||
|
|
<DoubleAnimation
|
||
|
|
Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Opacity)"
|
||
|
|
From="0.0"
|
||
|
|
To="1.0"
|
||
|
|
Duration="0:0:.16" />
|
||
|
|
</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 TargetName="SymbolIcon" Property="Visibility" Value="Collapsed" />
|
||
|
|
<Setter TargetName="SymbolIcon" Property="Margin" Value="0" />
|
||
|
|
</Trigger>
|
||
|
|
<Trigger Property="HasItems" Value="False">
|
||
|
|
<Setter TargetName="Expander" Property="Visibility" Value="Hidden" />
|
||
|
|
</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.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>
|