| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:converters="clr-namespace:Muchinfo.MTPClient.Converters">
- <converters:TreeViewLineConverter x:Key="TreeViewLineConverter" />
- <converters:NewTreeViewLineConverter x:Key="NewTreeViewLineConverter" />
- <!-- 折叠按钮 -->
- <Style x:Key="ExpandToggleButtonStyle" TargetType="{x:Type ToggleButton}">
- <Setter Property="Focusable" Value="False" />
- <Setter Property="Margin" Value="0,5.5,0,0" />
- <Setter Property="Width" Value="19" />
- <Setter Property="Height" Value="13" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ToggleButton}">
- <Border Width="19"
- Height="13"
- Background="Transparent">
- <Border Width="9"
- Height="9"
- Background="{DynamicResource TreeBackground}"
- BorderBrush="{DynamicResource TreeForeground}"
- BorderThickness="1"
- SnapsToDevicePixels="true">
- <Path x:Name="ExpandPath"
- Margin="1,1,1,1"
- Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z"
- Fill="{DynamicResource TreeForeground}" />
- </Border>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsChecked" Value="True">
- <Setter TargetName="ExpandPath" Property="Data" Value="M 0 2 L 0 3 L 5 3 L 5 2 Z" />
- </Trigger>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="ExpandPath" Property="Fill" Value="White" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!-- 显示虚线样式TreeViewItem -->
- <Style x:Key="LineTreeViewItem" TargetType="{x:Type TreeViewItem}">
- <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
- <Setter Property="IsEnabled" Value="{Binding IsEnabled}" />
- <Setter Property="Background" Value="{DynamicResource TreeBackground}" />
- <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
- <Setter Property="Foreground" Value="{DynamicResource TreeForeground}" />
- <Setter Property="BorderBrush" Value="{DynamicResource CommonBorderBrush}" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type TreeViewItem}">
- <!-- <ColumnDefinition Width="*" /> -->
- <Grid>
- <!--
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" MinWidth="19" />
- <ColumnDefinition Width="auto" />
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition />
- </Grid.RowDefinitions>
- -->
- <StackPanel Orientation="Vertical">
- <StackPanel Orientation="Horizontal">
- <ToggleButton x:Name="Expander"
- VerticalAlignment="Center"
- BorderBrush="{TemplateBinding BorderBrush}"
- ClickMode="Press"
- IsChecked="{Binding IsExpanded,
- RelativeSource={RelativeSource TemplatedParent}}"
- Style="{StaticResource ExpandToggleButtonStyle}" />
- <Rectangle x:Name="VerLn"
- Grid.RowSpan="2"
- Width="1"
- Margin="10,0,0,0"
- SnapsToDevicePixels="true"
- Stretch="Fill"
- Stroke="{DynamicResource TreeForeground}"
- StrokeDashArray="1,3"
- StrokeThickness="1" />
- <Rectangle x:Name="HorLn"
- Width="20"
- Height="1"
- SnapsToDevicePixels="true"
- Stroke="{DynamicResource TreeForeground}"
- StrokeDashArray="1,3"
- StrokeThickness="1" />
- <Border x:Name="Bd"
- Grid.Column="1"
- Background="{TemplateBinding Background}"
- BorderBrush="{TemplateBinding BorderBrush}"
- BorderThickness="{TemplateBinding BorderThickness}"
- Padding="{TemplateBinding Padding}">
- <ContentPresenter x:Name="PART_Header"
- Margin="3"
- HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
- ContentSource="Header" />
- </Border>
- </StackPanel>
- <ItemsPresenter x:Name="ItemsHost"
- Grid.Row="1"
- Grid.Column="1"
- Grid.ColumnSpan="2" />
- </StackPanel>
- </Grid>
- <ControlTemplate.Triggers>
- <!-- 无父无子的项不显示线 -->
- <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource NewTreeViewLineConverter}}" Value="true">
- <Setter TargetName="HorLn" Property="Visibility" Value="Collapsed" />
- <Setter TargetName="VerLn" Property="Visibility" Value="Collapsed" />
- <Setter TargetName="Expander" Property="Visibility" Value="Collapsed" />
- <Setter TargetName="Bd" Property="Margin" Value="20,0" />
- </DataTrigger>
- <!-- 最后一项竖线的显示问题 -->
- <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource TreeViewLineConverter}}" Value="true">
- <Setter TargetName="VerLn" Property="Height" Value="9" />
- <Setter TargetName="VerLn" Property="VerticalAlignment" Value="Top" />
- </DataTrigger>
- <Trigger Property="IsExpanded" Value="false">
- <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed" />
- </Trigger>
- <Trigger Property="HasItems" Value="false">
- <Setter TargetName="Expander" Property="Visibility" Value="Collapsed" />
- </Trigger>
- <Trigger Property="HasItems" Value="true">
- <Setter TargetName="VerLn" Property="Visibility" Value="Collapsed" />
- <Setter TargetName="HorLn" Property="Visibility" Value="Collapsed" />
- </Trigger>
- <Trigger Property="IsSelected" Value="true">
- <Setter Property="Foreground" Value="{DynamicResource TreeItemSelectedForeground}" />
- </Trigger>
- <Trigger Property="IsMouseOver" Value="true">
- <Setter Property="Foreground" Value="{DynamicResource TreeMouseOverForeground}" />
- <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ExpanderHeadBrush}" />
- </Trigger>
- <Trigger Property="IsEnabled" Value="False">
- <Setter Property="Foreground" Value="{DynamicResource DisEnableBrush}" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Setter Property="ItemsPanel">
- <Setter.Value>
- <ItemsPanelTemplate>
- <StackPanel />
- </ItemsPanelTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </ResourceDictionary>
|