-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathBreadcrumbTreeItem.xaml
118 lines (112 loc) · 7.33 KB
/
BreadcrumbTreeItem.xaml
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
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrls="clr-namespace:BmLib.Controls"
xmlns:uc="clr-namespace:BmLib.Controls.Breadcrumbs"
xmlns:conv="clr-namespace:BmLib.Converters"
xmlns:reskeys="clr-namespace:BmLib.Themes"
xmlns:behav="clr-namespace:BmLib.Behaviors"
>
<!-- Defines the default style which is loaded through Themes/Generic.xaml
via style key property registered in static constructor -->
<Style TargetType="{x:Type uc:BreadcrumbTreeItem}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static reskeys:ResourceKeys.ControlBorderBrushKey}}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type uc:BreadcrumbTreeItem}">
<!-- The orientation in this panel layouts sub-items horizontally -->
<ctrls:OverflowableStackPanel HorizontalAlignment="Stretch"
Orientation="Horizontal"
OverflowItemCount="{Binding OverflowItemCount, RelativeSource={RelativeSource TemplatedParent}
, Mode=OneWayToSource}" >
<ctrls:HotTrack x:Name="headerHL"
ctrls:OverflowableStackPanel.CanOverflow="True"
SelectedBorderBrush="{TemplateBinding BorderBrush}"
MaxWidth="1000"
BorderThickness="1"
BorderBrush="Transparent"
>
<Grid Background="Transparent">
<Grid.Resources>
<conv:BoolToVisibilityPropConverter TrueValue="Visible" FalseValue="Collapsed" x:Key="BoolToVisibilityConverter" />
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" x:Name="PART_CaptionButton"
Template="{DynamicResource {x:Static reskeys:ResourceKeys.BaseButton}}"
MaxWidth="1000"
Margin="0"
Padding="0"
Command="{TemplateBinding ClickItemCommand}"
>
<ContentPresenter x:Name="PART_Header"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
ContentSource="Header" />
</Button>
<ctrls:DropDownList x:Name="PART_Toggle"
Grid.Column="1"
Margin="0"
Padding="0"
ItemsSource="{TemplateBinding ItemsSource}"
Visibility="{Binding HasItems, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BoolToVisibilityConverter}}"
SelectedValuePath="{Binding ValuePath, RelativeSource={RelativeSource TemplatedParent}}"
SelectedValue="{Binding SelectedChild, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource TemplatedParent}}"
ItemTemplate="{TemplateBinding DropDownListItemDataTemplate}"
behav:SelectionChangedCommand.ChangedCommand="{Binding Path=DropDownItemSelectedCommand}"
>
<!--
Binding this causes problems with virtualized treeview
If Binding should be necessary (don't see the point right now) we should bind to something else
IsDropDownOpen="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
-->
</ctrls:DropDownList>
</Grid>
</ctrls:HotTrack>
<ItemsPresenter x:Name="ItemsHost" />
</ctrls:OverflowableStackPanel>
<ControlTemplate.Triggers>
<MultiTrigger >
<MultiTrigger.Conditions>
<Condition Property="IsChildSelected" Value="false" />
<Condition Property="IsCurrentSelected" Value="false" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<Setter Property="Visibility" Value="Collapsed"/>
</MultiTrigger.Setters>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<!--Style.Triggers>
-This trigger is needed, because RelativeSource binding can only succeed if the current item is already connected to its visual parent-
<Trigger Property="IsVisible" Value="True">
<Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
<Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
</Trigger>
</Style.Triggers-->
<Style.Triggers>
<Trigger Property="VirtualizingStackPanel.IsVirtualizing" Value="True">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>