Skip to content

Commit 8e7b542

Browse files
committed
Fix issue (#152, #153
Fix issue (#152, #153
1 parent 200f06d commit 8e7b542

File tree

7 files changed

+278
-21
lines changed

7 files changed

+278
-21
lines changed

src/WPFDevelopers.Shared/Styles/Styles.TreeView.xaml src/WPFDevelopers.Net40/Styles/Styles.TreeView.xaml

+24-15
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212
x:Key="WD.DefaultTreeView"
1313
BasedOn="{StaticResource WD.ControlBasicStyle}"
1414
TargetType="{x:Type TreeView}">
15-
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
16-
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
1715
<Setter Property="BorderThickness" Value="1" />
1816
<Setter Property="Background" Value="{DynamicResource WD.BackgroundBrush}" />
1917
<Setter Property="BorderBrush" Value="{DynamicResource WD.BaseBrush}" />
2018
<Setter Property="Padding" Value="{StaticResource WD.Padding}" />
19+
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
20+
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
21+
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
22+
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
23+
<Setter Property="VerticalContentAlignment" Value="Center" />
2124
<Setter Property="Template">
2225
<Setter.Value>
23-
<ControlTemplate TargetType="TreeView">
26+
<ControlTemplate TargetType="{x:Type TreeView}">
2427
<controls:WDBorder
2528
Padding="{TemplateBinding Padding}"
2629
Background="{TemplateBinding Background}"
@@ -29,9 +32,15 @@
2932
CornerRadius="{Binding Path=(helpers:ElementHelper.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
3033
SnapsToDevicePixels="True">
3134
<ScrollViewer
35+
x:Name="PART_ScrollViewer"
36+
Padding="{TemplateBinding Padding}"
37+
Background="{TemplateBinding Background}"
3238
CanContentScroll="False"
3339
Clip="{Binding RelativeSource={RelativeSource AncestorType=controls:WDBorder}, Path=ContentClip}"
34-
Focusable="False">
40+
Focusable="false"
41+
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
42+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
43+
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
3544
<ItemsPresenter />
3645
</ScrollViewer>
3746
</controls:WDBorder>
@@ -125,13 +134,11 @@
125134
BasedOn="{StaticResource WD.ControlBasicStyle}"
126135
TargetType="{x:Type TreeViewItem}">
127136
<Setter Property="Background" Value="Transparent" />
128-
<Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
129-
<Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
137+
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
138+
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
130139
<Setter Property="Padding" Value="{Binding Padding, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ItemsControl}}}" />
131-
<Setter Property="FocusVisualStyle" Value="{StaticResource WD.TreeViewItemFocusVisual}" />
132-
<Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource AncestorType=TreeView}, Path=FontSize}" />
133-
<Setter Property="FontWeight" Value="{Binding RelativeSource={RelativeSource AncestorType=TreeView}, Path=FontWeight}" />
134-
<Setter Property="FontFamily" Value="{Binding RelativeSource={RelativeSource AncestorType=TreeView}, Path=FontFamily}" />
140+
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
141+
<Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}" />
135142
<Setter Property="Template">
136143
<Setter.Value>
137144
<ControlTemplate TargetType="{x:Type TreeViewItem}">
@@ -143,12 +150,12 @@
143150
</Grid.ColumnDefinitions>
144151
<Grid.RowDefinitions>
145152
<RowDefinition Height="Auto" />
146-
<RowDefinition Height="Auto" />
153+
<RowDefinition />
147154
</Grid.RowDefinitions>
148155
<ToggleButton
149156
x:Name="Expander"
150157
ClickMode="Press"
151-
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
158+
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource Mode=TemplatedParent}}"
152159
Style="{StaticResource WD.ExpandCollapseToggleStyle}" />
153160
<Border
154161
x:Name="PART_Border"
@@ -162,7 +169,8 @@
162169
<ContentPresenter
163170
x:Name="PART_Header"
164171
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
165-
ContentSource="Header" />
172+
ContentSource="Header"
173+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
166174
</Border>
167175
<Border
168176
x:Name="PART_ItemsHost"
@@ -206,15 +214,16 @@
206214
<MultiTrigger>
207215
<MultiTrigger.Conditions>
208216
<Condition Property="IsSelected" Value="True" />
209-
<Condition Property="IsSelectionActive" Value="False" />
217+
<Condition SourceName="PART_Border" Property="IsMouseOver" Value="True" />
210218
</MultiTrigger.Conditions>
211-
<Setter TargetName="PART_Border" Property="Background" Value="{DynamicResource WD.BackgroundBrush}" />
219+
<Setter TargetName="PART_Border" Property="Background" Value="{DynamicResource WD.BaseMoveBrush}" />
212220
</MultiTrigger>
213221
</ControlTemplate.Triggers>
214222
</ControlTemplate>
215223
</Setter.Value>
216224
</Setter>
217225
</Style>
226+
218227
<Style BasedOn="{StaticResource WD.DefaultTreeView}" TargetType="{x:Type TreeView}" />
219228
<Style BasedOn="{StaticResource WD.DefaultTreeViewItem}" TargetType="{x:Type TreeViewItem}" />
220229
</ResourceDictionary>

src/WPFDevelopers.Net40/WPFDevelopers.Net40.csproj.user

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup />
44
<ItemGroup>
5+
<Page Update="Styles\Styles.TreeView.xaml">
6+
<SubType>Designer</SubType>
7+
</Page>
58
<Page Update="Themes\Theme.xaml">
69
<SubType>Designer</SubType>
710
</Page>

0 commit comments

Comments
 (0)