alielie
2025-11-25 006c98e5650b530e5220f279c1e803fefe69d40d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:controls="clr-namespace:HMI.UI">
 
    <Style TargetType="{x:Type controls:TreeListView}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:TreeListView}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        Background="{TemplateBinding Background}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <GridViewHeaderRowPresenter Grid.Row="0" 
                                                        Columns="{TemplateBinding Columns}"/>
                            <ScrollViewer Grid.Row="1" Padding="{TemplateBinding Padding}" VerticalScrollBarVisibility="Auto">
                                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
 
    <!--<Style x:Key="ExpandCollapseToggleStyle" TargetType="ToggleButton">
        <Setter Property="Width" Value="10"/>
        <Setter Property="Height" Value="10"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="ToggleButton.RenderTransformOrigin" Value="0.5,0.5"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Path x:Name="ExpandPath" Margin="0" Fill="Black" Stroke="Black" 
                      Data="M 4 0 L 10 5 L 4 10 Z"/>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="ToggleButton.RenderTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="90"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>-->
 
    <Style x:Key="ExpandCollapseToggleStyle" TargetType="ToggleButton">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Border Background="Transparent" Cursor="Hand">
                        <Grid x:Name="cross" Height="16"  Width="16" >
                            <Path Data="M 0.5,0.5 l 15,0 l 0,15 l -15,0 L 0.5,0" Stroke="{TemplateBinding Foreground}" StrokeThickness="1"/>
                            <Path x:Name="cross_h" Data="M 3,7.5 l 9,0" Stroke="{TemplateBinding Foreground}" StrokeThickness="1"/>
                            <Path x:Name="cross_v" Data="M 7.5,3 l 0,9" Stroke="{TemplateBinding Foreground}" StrokeThickness="1"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="Visibility" TargetName="cross_v" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
 
    <ControlTemplate x:Key="tvi" TargetType="{x:Type controls:TreeListViewItem}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
 
            <Border x:Name="Bd"
            Grid.Column="1"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            Padding="{TemplateBinding Padding}">
 
                <!--<GridViewRowPresenter x:Name="sb" Grid.Column="1" Columns="{TemplateBinding Columns}" 
                                      Content="{Binding }"/>-->
 
                <ContentPresenter Grid.Column="0" x:Name="cp"
        Content="{TemplateBinding Header}"
        ContentTemplate="{TemplateBinding HeaderTemplate}"
        ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"/>
 
                <!--<Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                
                -->
                <!--<GridViewRowPresenter Grid.Column="1" Columns="{TemplateBinding Columns}" 
                                      Content="{Binding }"/>-->
                <!--
            </Grid>-->
            </Border>
 
            <ItemsPresenter x:Name="ItemsHost"
                  Grid.Row="1"
                  Grid.Column="1"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsExpanded" Value="False">
                <Setter Property="Visibility" Value="Collapsed" TargetName="ItemsHost"/>
            </Trigger>
            <DataTrigger Binding="{Binding IsSelected,RelativeSource={RelativeSource Mode=Self}}" Value="True">
                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                <Setter Property="TextBlock.Foreground" TargetName="cp"  Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
            </DataTrigger>
            <!--<DataTrigger Binding="{Binding IsMouseOver,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=controls:TreeListViewItem,AncestorLevel=1}}" Value="True">
            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
        </DataTrigger>-->
        </ControlTemplate.Triggers>
    </ControlTemplate>
 
    <Style TargetType="{x:Type controls:TreeListViewItem}">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template" Value="{StaticResource tvi}"/>
    </Style>
</ResourceDictionary>