1
+ <ResourceDictionary xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2
+ xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
3
+ xmlns : i =" http://schemas.microsoft.com/expression/2010/interactivity" >
4
+
5
+ <ControlTemplate x : Key =" ComboBoxToggleButton" TargetType =" {x:Type ToggleButton}" >
6
+ <Grid >
7
+ <Grid .ColumnDefinitions>
8
+ <ColumnDefinition />
9
+ <ColumnDefinition Width =" 20" />
10
+ </Grid .ColumnDefinitions>
11
+ <Border Style =" {StaticResource DefaultBorder}"
12
+ x : Name =" Border"
13
+ Grid.ColumnSpan=" 2"
14
+ Background =" {StaticResource ControlLightBrush}"
15
+ BorderBrush =" {StaticResource AccentBrush}"
16
+ BorderThickness =" 1" />
17
+ <Border
18
+ Grid.Column=" 0"
19
+ CornerRadius =" 0"
20
+ Margin =" 10,1,0,1"
21
+ Background =" {Binding ElementName=Border, Path=Background}"
22
+ BorderBrush =" {Binding ElementName=Border, Path=BorderBrush}"
23
+ BorderThickness =" 0,0,1,0" />
24
+ <Path
25
+ x : Name =" Arrow"
26
+ Grid.Column=" 1"
27
+ Fill =" {StaticResource GlyphBrush}"
28
+ HorizontalAlignment =" Center"
29
+ VerticalAlignment =" Center"
30
+ Data =" M0,0 L0,2 L4,6 L8,2 L8,0 L4,4 z"
31
+ />
32
+ </Grid >
33
+ <ControlTemplate .Triggers>
34
+ <Trigger Property =" ToggleButton.IsMouseOver" Value =" true" >
35
+ <Setter TargetName =" Border" Property =" Background" Value =" {StaticResource MouseOverBrush}" />
36
+ </Trigger >
37
+ <Trigger Property =" ToggleButton.IsChecked" Value =" true" >
38
+ <Setter TargetName =" Border" Property =" Background" Value =" {StaticResource AccentBrush}" />
39
+ </Trigger >
40
+ <Trigger Property =" IsEnabled" Value =" False" >
41
+ <Setter TargetName =" Border" Property =" Background" Value =" {StaticResource DisabledAccentBrush}" />
42
+ <Setter TargetName =" Border" Property =" BorderBrush" Value =" {StaticResource DisabledAccentBrush}" />
43
+ <Setter Property =" Foreground" Value =" Black" />
44
+ <Setter TargetName =" Arrow" Property =" Fill" Value =" {StaticResource GlyphBrush}" />
45
+ </Trigger >
46
+ </ControlTemplate .Triggers>
47
+ </ControlTemplate >
48
+
49
+ <ControlTemplate x : Key =" ComboBoxTextBox" TargetType =" {x:Type TextBox}" >
50
+ <Border x : Name =" PART_ContentHost" Focusable =" False" Background =" {TemplateBinding Background}" />
51
+ </ControlTemplate >
52
+
53
+ <Style x : Key =" StyledComboBox" TargetType =" {x:Type ComboBox}" >
54
+ <Setter Property =" SnapsToDevicePixels" Value =" true" />
55
+ <Setter Property =" OverridesDefaultStyle" Value =" true" />
56
+ <Setter Property =" ScrollViewer.HorizontalScrollBarVisibility" Value =" Auto" />
57
+ <Setter Property =" ScrollViewer.VerticalScrollBarVisibility" Value =" Auto" />
58
+ <Setter Property =" ScrollViewer.CanContentScroll" Value =" true" />
59
+ <Setter Property =" MinWidth" Value =" 120" />
60
+ <Setter Property =" MinHeight" Value =" 20" />
61
+ <Setter Property =" Foreground" Value =" Black" />
62
+ <Setter Property =" Template" >
63
+ <Setter .Value>
64
+ <ControlTemplate TargetType =" {x:Type ComboBox}" >
65
+ <Grid >
66
+ <ToggleButton
67
+ Name =" ToggleButton"
68
+ Template =" {StaticResource ComboBoxToggleButton}"
69
+ Grid.Column=" 2"
70
+ Focusable =" false"
71
+ IsChecked =" {Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
72
+ ClickMode =" Press" >
73
+ </ToggleButton >
74
+ <ContentPresenter Name =" ContentSite" IsHitTestVisible =" False" Content =" {TemplateBinding SelectionBoxItem}"
75
+ ContentTemplate =" {TemplateBinding SelectionBoxItemTemplate}"
76
+ ContentTemplateSelector =" {TemplateBinding ItemTemplateSelector}"
77
+ Margin =" 5,3,23,3"
78
+ VerticalAlignment =" Center"
79
+ HorizontalAlignment =" Left" />
80
+ <TextBox x : Name =" PART_EditableTextBox"
81
+ Style =" {x:Null}"
82
+ Template =" {StaticResource ComboBoxTextBox}"
83
+ HorizontalAlignment =" Left"
84
+ VerticalAlignment =" Center"
85
+ Margin =" 5,5,23,3"
86
+ Focusable =" True"
87
+ Background =" {StaticResource ControlLightBrush}"
88
+ Visibility =" Hidden"
89
+ IsReadOnly =" {TemplateBinding IsReadOnly}" />
90
+ <Popup
91
+ Name =" Popup"
92
+ Placement =" Bottom"
93
+ IsOpen =" {TemplateBinding IsDropDownOpen}"
94
+ AllowsTransparency =" True"
95
+ Focusable =" False"
96
+ PopupAnimation =" Slide" >
97
+
98
+ <Grid Name =" DropDown"
99
+ SnapsToDevicePixels =" True"
100
+ MinWidth =" {TemplateBinding ActualWidth}"
101
+ MaxHeight =" {TemplateBinding MaxDropDownHeight}" >
102
+ <Border
103
+ x : Name =" DropDownBorder" Style =" {StaticResource DefaultBorder}" CornerRadius =" 5"
104
+ Background =" {StaticResource ControlLightBrush}" BorderThickness =" 1,1,1,1" />
105
+ <ScrollViewer Margin =" 4,6,4,6" SnapsToDevicePixels =" True" >
106
+ <StackPanel IsItemsHost =" True" KeyboardNavigation.DirectionalNavigation=" Contained" />
107
+ </ScrollViewer >
108
+ </Grid >
109
+ </Popup >
110
+ </Grid >
111
+ <ControlTemplate .Triggers>
112
+ <Trigger Property =" HasItems" Value =" false" >
113
+ <Setter TargetName =" DropDownBorder" Property =" MinHeight" Value =" 95" />
114
+ </Trigger >
115
+ <Trigger Property =" IsEnabled" Value =" false" >
116
+ <Setter Property =" Foreground" Value =" {StaticResource DisabledControlDarkColor}" />
117
+ </Trigger >
118
+ <Trigger Property =" IsGrouping" Value =" true" >
119
+ <Setter Property =" ScrollViewer.CanContentScroll" Value =" false" />
120
+ </Trigger >
121
+ <Trigger SourceName =" Popup" Property =" Popup.AllowsTransparency" Value =" true" >
122
+ <Setter TargetName =" DropDownBorder" Property =" CornerRadius" Value =" 0" />
123
+ <Setter TargetName =" DropDownBorder" Property =" Margin" Value =" 0,2,0,0" />
124
+ </Trigger >
125
+ <Trigger Property =" IsEditable" Value =" true" >
126
+ <Setter Property =" IsTabStop" Value =" false" />
127
+ <Setter TargetName =" PART_EditableTextBox" Property =" Visibility" Value =" Visible" />
128
+ <Setter TargetName =" ContentSite" Property =" Visibility" Value =" Hidden" />
129
+ </Trigger >
130
+ </ControlTemplate .Triggers>
131
+ </ControlTemplate >
132
+ </Setter .Value>
133
+ </Setter >
134
+ <Style .Triggers>
135
+ </Style .Triggers>
136
+ </Style >
137
+
138
+ <Style x : Key =" {x:Type ComboBoxItem}" TargetType =" {x:Type ComboBoxItem}" >
139
+ <Setter Property =" SnapsToDevicePixels" Value =" true" />
140
+ <Setter Property =" Foreground" Value =" Black" />
141
+ <Setter Property =" OverridesDefaultStyle" Value =" true" />
142
+ <Setter Property =" Template" >
143
+ <Setter .Value>
144
+ <ControlTemplate TargetType =" {x:Type ComboBoxItem}" >
145
+ <Border Name =" Border"
146
+ Padding =" 2"
147
+ SnapsToDevicePixels =" true" >
148
+ <ContentPresenter />
149
+ </Border >
150
+ <ControlTemplate .Triggers>
151
+ <Trigger Property =" IsHighlighted" Value =" true" >
152
+ <Setter TargetName =" Border" Property =" Background" Value =" {StaticResource MouseOverBrush}" />
153
+ </Trigger >
154
+ <Trigger Property =" IsEnabled" Value =" false" >
155
+ <Setter Property =" Foreground" Value =" {StaticResource DisabledControlDarkColor}" />
156
+ </Trigger >
157
+ </ControlTemplate .Triggers>
158
+
159
+ </ControlTemplate >
160
+ </Setter .Value>
161
+ </Setter >
162
+ </Style >
163
+ <Style TargetType =" ComboBox" BasedOn =" {StaticResource StyledComboBox}" />
164
+
165
+ </ResourceDictionary >
0 commit comments