chr
2026-04-05 fe750b791d5b517cc4e9bc8e99a9a75139a0cfba
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:controls="clr-namespace:UILib">
 
    <controls:IndentConverter x:Key="IndentConverter"/>
 
    <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/>
                                <RowDefinition Height="Auto"/>
                            </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="TreeTotalIndex" TargetType="TextBlock">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Text">
            <Setter.Value>
                <MultiBinding Converter="{x:Static controls:TreeListViewButtonConverter.Instance}" ConverterParameter="Index">
                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}"/>
                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="level" />
                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="index" />
                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="IsExpanded" />
                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="IsLastNode" />
                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="HasItems" />
                </MultiBinding>
            </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">
                    <Grid x:Name="cross" Cursor="Hand">
                        <Path Fill="LightYellow" Height="{Binding ActualHeight,RelativeSource={RelativeSource AncestorLevel=1,AncestorType=Control}}" 
                              Margin="0" Stroke="{TemplateBinding Foreground}" StrokeThickness="1">
                            <Path.Width>
                                <MultiBinding Converter="{x:Static controls:TreeListViewButtonConverter.Instance}" ConverterParameter="Size">
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}"/>
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="level" />
                                    <Binding RelativeSource="{RelativeSource Mode=Self}" Path="Height"/>
                                </MultiBinding>
                            </Path.Width>
 
                            <Path.Data>
                                <MultiBinding Converter="{x:Static controls:TreeListViewButtonConverter.Instance}" ConverterParameter="Content">
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}"/>
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="level" />
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="index" />
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="IsExpanded" />
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="IsLastNode" />
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="HasItems" />
                                    <Binding RelativeSource="{RelativeSource Mode=Self}" Path="Height"/>
                                </MultiBinding>
                            </Path.Data>
                        </Path>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
 
    <Style x:Key="SimpleToggleButton" TargetType="ToggleButton">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="ClickMode" Value="Press"/>
        <Setter Property="IsChecked" Value="{Binding IsExpanded, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=controls:TreeListViewItem,AncestorLevel=1}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid x:Name="cross" Cursor="Hand">
                        <Path Fill="Transparent" Height="{Binding ActualHeight,RelativeSource={RelativeSource AncestorLevel=1,AncestorType=Control}}"
                              Margin="0" Stroke="{TemplateBinding Foreground}" StrokeThickness="1">
                            <Path.Width>
                                <MultiBinding Converter="{x:Static controls:SimpleTreeListViewButtonConverter.Instance}" ConverterParameter="Size">
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}"/>
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="level" />
                                    <Binding RelativeSource="{RelativeSource Mode=Self}" Path="Height"/>
                                </MultiBinding>
                            </Path.Width>
 
                            <Path.Data>
                                <MultiBinding Converter="{x:Static controls:SimpleTreeListViewButtonConverter.Instance}" ConverterParameter="Content">
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}"/>
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="level" />
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="index" />
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="IsExpanded" />
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="IsLastNode" />
                                    <Binding RelativeSource="{RelativeSource AncestorType=controls:TreeListViewItem,AncestorLevel=1,Mode=FindAncestor}" Path="HasItems" />
                                    <Binding RelativeSource="{RelativeSource Mode=Self}" Path="Height"/>
                                </MultiBinding>
                            </Path.Data>
                        </Path>
                    </Grid>
                </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 Margin="0" 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>
 
    <Style TargetType="{x:Type controls:EditBox}">
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:EditBox}">
                    <Grid Cursor="Hand" MinWidth="{TemplateBinding MinWidth}" Background="{TemplateBinding Background}">
                        <Border x:Name="PART_BoraderPart" VerticalAlignment="Center" Padding="0" Margin="0">
                            <Border.Style>
                                <Style TargetType="Border">
                                    <Setter Property="BorderThickness" Value="0"/>
                                    <Setter Property="BorderBrush" Value="Transparent"/>
                                    <Style.Triggers>
                                        <MultiDataTrigger>
                                            <MultiDataTrigger.Conditions>
                                                <Condition Binding="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}}" Value=""/>
                                                <Condition Binding="{Binding Path=ShowEmpty, RelativeSource={RelativeSource TemplatedParent}}" Value="True"/>
                                            </MultiDataTrigger.Conditions>
                                            <MultiDataTrigger.Setters>
                                                <Setter Property="BorderBrush" Value="Black"/>
                                                <Setter Property="BorderThickness" Value="0,0,0,0.6"/>
                                            </MultiDataTrigger.Setters>
                                        </MultiDataTrigger>
                                        <MultiDataTrigger>
                                            <MultiDataTrigger.Conditions>
                                                <Condition Binding="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}}" Value="{x:Null}"/>
                                                <Condition Binding="{Binding Path=ShowEmpty, RelativeSource={RelativeSource TemplatedParent}}" Value="True"/>
                                            </MultiDataTrigger.Conditions>
                                            <MultiDataTrigger.Setters>
                                                <Setter Property="BorderBrush" Value="Black"/>
                                                <Setter Property="BorderThickness" Value="0,0,0,0.6"/>
                                            </MultiDataTrigger.Setters>
                                        </MultiDataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
 
                            <Border BorderThickness="1" BorderBrush="Transparent">
                                <TextBlock x:Name="PART_TextBlockPart" FontSize="{TemplateBinding FontSize}" 
                                           TextWrapping="NoWrap" Padding="0" VerticalAlignment="Center" 
                                           Text="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}}"/>
                            </Border>
                        </Border>
                        <TextBox x:Name="PART_TextBoxPart" BorderThickness="1" Padding="0" Background="#FFF"
                                   FontSize="{TemplateBinding FontSize}" Visibility="Collapsed"
                           Text="{Binding Path=Value, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource TemplatedParent}}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>