Skip to content

Commit 004cb69

Browse files
committed
feat(style): add TreeView small style
1 parent ab11cb6 commit 004cb69

File tree

6 files changed

+53
-16
lines changed

6 files changed

+53
-16
lines changed

src/Net_40/HandyControl_Net_40/Themes/Styles/Base/TreeViewBaseStyle.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@
3636
<Setter Property="Background" Value="Transparent"/>
3737
<Setter Property="Padding" Value="10,0"/>
3838
<Setter Property="BorderThickness" Value="0"/>
39+
<Setter Property="MinHeight" Value="{StaticResource DefaultControlHeight}"/>
3940
<Setter Property="Template">
4041
<Setter.Value>
4142
<ControlTemplate TargetType="TreeViewItem">
4243
<Grid>
4344
<Grid.RowDefinitions>
44-
<RowDefinition MinHeight="{StaticResource DefaultControlHeight}"/>
45-
<RowDefinition/>
45+
<RowDefinition MinHeight="{TemplateBinding MinHeight}"/>
46+
<RowDefinition Height="Auto"/>
4647
</Grid.RowDefinitions>
4748
<Border x:Name="Bd" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
4849
<DockPanel LastChildFill="True" Margin="{Binding Converter={StaticResource TreeViewItemMarginConverter}, RelativeSource={RelativeSource TemplatedParent}}">

src/Net_40/HandyControl_Net_40/Themes/Theme.xaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11535,13 +11535,14 @@
1153511535
<Setter Property="Background" Value="Transparent" />
1153611536
<Setter Property="Padding" Value="10,0" />
1153711537
<Setter Property="BorderThickness" Value="0" />
11538+
<Setter Property="MinHeight" Value="{StaticResource DefaultControlHeight}" />
1153811539
<Setter Property="Template">
1153911540
<Setter.Value>
1154011541
<ControlTemplate TargetType="TreeViewItem">
1154111542
<Grid>
1154211543
<Grid.RowDefinitions>
11543-
<RowDefinition MinHeight="{StaticResource DefaultControlHeight}" />
11544-
<RowDefinition />
11544+
<RowDefinition MinHeight="{TemplateBinding MinHeight}" />
11545+
<RowDefinition Height="Auto" />
1154511546
</Grid.RowDefinitions>
1154611547
<Border x:Name="Bd" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
1154711548
<DockPanel LastChildFill="True" Margin="{Binding Converter={StaticResource TreeViewItemMarginConverter}, RelativeSource={RelativeSource TemplatedParent}}">
@@ -13269,6 +13270,13 @@
1326913270
<Style BasedOn="{StaticResource TransferBaseStyle}" TargetType="hc:Transfer" />
1327013271
<Style BasedOn="{StaticResource TreeViewItemBaseStyle}" TargetType="TreeViewItem" />
1327113272
<Style BasedOn="{StaticResource TreeViewBaseStyle}" TargetType="TreeView" />
13273+
<Style x:Key="TreeViewItemBaseStyle.Small" BasedOn="{StaticResource TreeViewItemBaseStyle}" TargetType="TreeViewItem">
13274+
<Setter Property="Padding" Value="6,0" />
13275+
<Setter Property="MinHeight" Value="24" />
13276+
</Style>
13277+
<Style x:Key="TreeView.Small" BasedOn="{StaticResource TreeViewBaseStyle}" TargetType="TreeView">
13278+
<Setter Property="ItemContainerStyle" Value="{StaticResource TreeViewItemBaseStyle.Small}" />
13279+
</Style>
1327213280
<Style BasedOn="{StaticResource WatermarkBaseStyle}" TargetType="hc:Watermark" />
1327313281
<Style BasedOn="{StaticResource AutoCompleteTextBoxBaseStyle}" TargetType="hc:AutoCompleteTextBox" />
1327413282
<ControlTemplate x:Key="TipSliderThumbHorizontalTop" TargetType="Thumb">

src/Shared/HandyControlDemo_Shared/UserControl/Styles/TreeViewDemoCtl.xaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@
44
xmlns:hc="https://handyorg.github.io/handycontrol"
55
Background="{DynamicResource RegionBrush}">
66
<hc:TransitioningContentControl>
7-
<TreeView Width="200" Margin="32" ItemsSource="{Binding DataList}">
8-
<TreeView.ItemTemplate>
9-
<HierarchicalDataTemplate ItemsSource="{Binding DataList}">
10-
<TextBlock Text="{Binding Name}"/>
11-
</HierarchicalDataTemplate>
12-
</TreeView.ItemTemplate>
13-
</TreeView>
7+
<WrapPanel Margin="16">
8+
<TreeView Width="200" Margin="16" ItemsSource="{Binding DataList}">
9+
<TreeView.ItemTemplate>
10+
<HierarchicalDataTemplate ItemsSource="{Binding DataList}">
11+
<TextBlock Text="{Binding Name}"/>
12+
</HierarchicalDataTemplate>
13+
</TreeView.ItemTemplate>
14+
</TreeView>
15+
<TreeView Width="200" Margin="16" ItemsSource="{Binding DataList}" Style="{StaticResource TreeView.Small}">
16+
<TreeView.ItemTemplate>
17+
<HierarchicalDataTemplate ItemsSource="{Binding DataList}">
18+
<TextBlock Text="{Binding Name}"/>
19+
</HierarchicalDataTemplate>
20+
</TreeView.ItemTemplate>
21+
</TreeView>
22+
</WrapPanel>
1423
</hc:TransitioningContentControl>
1524
</UserControl>

src/Shared/HandyControl_Shared/Themes/Styles/Base/TreeViewBaseStyle.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@
3636
<Setter Property="Background" Value="Transparent"/>
3737
<Setter Property="Padding" Value="10,0"/>
3838
<Setter Property="BorderThickness" Value="0"/>
39+
<Setter Property="MinHeight" Value="{StaticResource DefaultControlHeight}"/>
3940
<Setter Property="Template">
4041
<Setter.Value>
4142
<ControlTemplate TargetType="TreeViewItem">
4243
<Grid>
4344
<Grid.RowDefinitions>
44-
<RowDefinition MinHeight="{StaticResource DefaultControlHeight}"/>
45-
<RowDefinition/>
45+
<RowDefinition MinHeight="{TemplateBinding MinHeight}"/>
46+
<RowDefinition Height="Auto"/>
4647
</Grid.RowDefinitions>
4748
<Border x:Name="Bd" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
4849
<DockPanel LastChildFill="True" Margin="{Binding Converter={StaticResource TreeViewItemMarginConverter}, RelativeSource={RelativeSource TemplatedParent}}">
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
23

34
<Style BasedOn="{StaticResource TreeViewItemBaseStyle}" TargetType="TreeViewItem"/>
45

56
<Style BasedOn="{StaticResource TreeViewBaseStyle}" TargetType="TreeView"/>
67

8+
<Style x:Key="TreeViewItemBaseStyle.Small" BasedOn="{StaticResource TreeViewItemBaseStyle}" TargetType="TreeViewItem">
9+
<Setter Property="Padding" Value="6,0"/>
10+
<Setter Property="MinHeight" Value="24"/>
11+
</Style>
12+
13+
<Style x:Key="TreeView.Small" BasedOn="{StaticResource TreeViewBaseStyle}" TargetType="TreeView">
14+
<Setter Property="ItemContainerStyle" Value="{StaticResource TreeViewItemBaseStyle.Small}"/>
15+
</Style>
16+
717
</ResourceDictionary>

src/Shared/HandyControl_Shared/Themes/Theme.xaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11653,13 +11653,14 @@
1165311653
<Setter Property="Background" Value="Transparent" />
1165411654
<Setter Property="Padding" Value="10,0" />
1165511655
<Setter Property="BorderThickness" Value="0" />
11656+
<Setter Property="MinHeight" Value="{StaticResource DefaultControlHeight}" />
1165611657
<Setter Property="Template">
1165711658
<Setter.Value>
1165811659
<ControlTemplate TargetType="TreeViewItem">
1165911660
<Grid>
1166011661
<Grid.RowDefinitions>
11661-
<RowDefinition MinHeight="{StaticResource DefaultControlHeight}" />
11662-
<RowDefinition />
11662+
<RowDefinition MinHeight="{TemplateBinding MinHeight}" />
11663+
<RowDefinition Height="Auto" />
1166311664
</Grid.RowDefinitions>
1166411665
<Border x:Name="Bd" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
1166511666
<DockPanel LastChildFill="True" Margin="{Binding Converter={StaticResource TreeViewItemMarginConverter}, RelativeSource={RelativeSource TemplatedParent}}">
@@ -13420,6 +13421,13 @@
1342013421
<Style BasedOn="{StaticResource TransferBaseStyle}" TargetType="hc:Transfer" />
1342113422
<Style BasedOn="{StaticResource TreeViewItemBaseStyle}" TargetType="TreeViewItem" />
1342213423
<Style BasedOn="{StaticResource TreeViewBaseStyle}" TargetType="TreeView" />
13424+
<Style x:Key="TreeViewItemBaseStyle.Small" BasedOn="{StaticResource TreeViewItemBaseStyle}" TargetType="TreeViewItem">
13425+
<Setter Property="Padding" Value="6,0" />
13426+
<Setter Property="MinHeight" Value="24" />
13427+
</Style>
13428+
<Style x:Key="TreeView.Small" BasedOn="{StaticResource TreeViewBaseStyle}" TargetType="TreeView">
13429+
<Setter Property="ItemContainerStyle" Value="{StaticResource TreeViewItemBaseStyle.Small}" />
13430+
</Style>
1342313431
<Style BasedOn="{StaticResource WatermarkBaseStyle}" TargetType="hc:Watermark" />
1342413432
<Style BasedOn="{StaticResource AutoCompleteTextBoxBaseStyle}" TargetType="hc:AutoCompleteTextBox" />
1342513433
<ControlTemplate x:Key="TipSliderThumbHorizontalTop" TargetType="Thumb">

0 commit comments

Comments
 (0)