Skip to content

Commit 4e86faf

Browse files
committed
ComboBox background
ComboBox uses Background property. Fix DownVertialOffset.
1 parent 8d69709 commit 4e86faf

File tree

1 file changed

+47
-40
lines changed

1 file changed

+47
-40
lines changed

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
<RowDefinition Height="*" />
3939
</Grid.RowDefinitions>
4040
<Border Background="Transparent"
41-
BorderBrush="{DynamicResource MaterialDesignShadowBrush}"
42-
BorderThickness="1"
43-
CornerRadius="2">
41+
BorderBrush="{DynamicResource MaterialDesignShadowBrush}"
42+
BorderThickness="1"
43+
CornerRadius="2">
4444
<Border.Effect>
4545
<BlurEffect Radius="6"/>
4646
</Border.Effect>
@@ -53,12 +53,13 @@
5353
<RowDefinition Height="Auto"/>
5454
<RowDefinition Height="Auto"/>
5555
</Grid.RowDefinitions>
56-
<Rectangle Grid.Row="0"
57-
Fill="{DynamicResource MaterialDesignPaper}"
58-
Height="{StaticResource PopupTopBottomMargin}"/>
56+
<Border Grid.Row="0"
57+
CornerRadius="2 2 0 0"
58+
Background="{Binding ElementName=templateRoot, Path=Background}"
59+
Height="{StaticResource PopupTopBottomMargin}"/>
5960
<ContentPresenter Grid.Row="1"/>
6061
<Rectangle Grid.Row="2"
61-
Fill="{DynamicResource MaterialDesignPaper}"
62+
Fill="{Binding ElementName=templateRoot, Path=Background}"
6263
Height="{StaticResource PopupContentPresenterExtend}"/>
6364

6465
<Grid Grid.Row="3">
@@ -69,18 +70,19 @@
6970
</Grid.ColumnDefinitions>
7071
<Rectangle Grid.Column="0"
7172
Width="{StaticResource PopupLeftRightMargin}"
72-
Fill="{DynamicResource MaterialDesignPaper}"/>
73+
Fill="{Binding ElementName=templateRoot, Path=Background}"/>
7374
<Grid Grid.Column="1"
7475
Width="{Binding ElementName=templateRoot, Path=ActualWidth}"
75-
Height="{Binding ElementName=templateRoot, Path=ActualHeight, Converter={StaticResource MathAddConverter}, ConverterParameter=12}"/>
76+
Height="{Binding ElementName=templateRoot, Path=ActualHeight}"/>
7677
<Rectangle Grid.Column="2"
7778
MinWidth="{StaticResource PopupLeftRightMargin}"
78-
Fill="{DynamicResource MaterialDesignPaper}"/>
79+
Fill="{Binding ElementName=templateRoot, Path=Background}"/>
7980
</Grid>
8081

81-
<Rectangle Grid.Row="4"
82-
Height="{StaticResource PopupTopBottomMargin}"
83-
Fill="{DynamicResource MaterialDesignPaper}" />
82+
<Border Grid.Row="4"
83+
CornerRadius="0 0 2 2"
84+
Height="{StaticResource PopupTopBottomMargin}"
85+
Background="{Binding ElementName=templateRoot, Path=Background}" />
8486
</Grid>
8587
</Grid>
8688
</ControlTemplate>
@@ -92,9 +94,9 @@
9294
<RowDefinition Height="*" />
9395
</Grid.RowDefinitions>
9496
<Border Background="Transparent"
95-
BorderBrush="{DynamicResource MaterialDesignShadowBrush}"
96-
BorderThickness="1"
97-
CornerRadius="2">
97+
BorderBrush="{DynamicResource MaterialDesignShadowBrush}"
98+
BorderThickness="1"
99+
CornerRadius="2">
98100
<Border.Effect>
99101
<BlurEffect Radius="6"/>
100102
</Border.Effect>
@@ -108,9 +110,10 @@
108110
<RowDefinition Height="*"/>
109111
<RowDefinition Height="Auto"/>
110112
</Grid.RowDefinitions>
111-
<Rectangle Grid.Row="0"
112-
Fill="{DynamicResource MaterialDesignPaper}"
113-
Height="{StaticResource PopupTopBottomMargin}"/>
113+
<Border Grid.Row="0"
114+
CornerRadius="2 2 0 0"
115+
Background="{Binding ElementName=templateRoot, Path=Background}"
116+
Height="{StaticResource PopupTopBottomMargin}"/>
114117

115118
<Grid Grid.Row="1">
116119
<Grid.ColumnDefinitions>
@@ -120,26 +123,27 @@
120123
</Grid.ColumnDefinitions>
121124
<Rectangle Grid.Column="0"
122125
Width="{StaticResource PopupLeftRightMargin}"
123-
Fill="{DynamicResource MaterialDesignPaper}"
126+
Fill="{Binding ElementName=templateRoot, Path=Background}"
124127
/>
125128
<Grid Grid.Column="1"
126129
Width="{Binding ElementName=templateRoot, Path=ActualWidth}"
127-
Height="{Binding ElementName=templateRoot, Path=ActualHeight, Converter={StaticResource MathAddConverter}, ConverterParameter=12}"/>
130+
Height="{Binding ElementName=templateRoot, Path=ActualHeight}"/>
128131
<Rectangle Grid.Column="2"
129132
MinWidth="{StaticResource PopupLeftRightMargin}"
130-
Fill="{DynamicResource MaterialDesignPaper}"
133+
Fill="{Binding ElementName=templateRoot, Path=Background}"
131134
/>
132135
</Grid>
133136

134137
<Rectangle Grid.Row="2"
135-
Fill="{DynamicResource MaterialDesignPaper}"
138+
Fill="{Binding ElementName=templateRoot, Path=Background}"
136139
Height="{StaticResource PopupContentPresenterExtend}"/>
137140

138141
<ContentPresenter Grid.Row="3"/>
139142

140-
<Rectangle Grid.Row="4"
141-
Height="{StaticResource PopupTopBottomMargin}"
142-
Fill="{DynamicResource MaterialDesignPaper}" />
143+
<Border Grid.Row="4"
144+
CornerRadius="0 0 2 2"
145+
Height="{StaticResource PopupTopBottomMargin}"
146+
Background="{Binding ElementName=templateRoot, Path=Background}" />
143147
</Grid>
144148
</Grid>
145149
</ControlTemplate>
@@ -151,9 +155,9 @@
151155
<RowDefinition Height="*" />
152156
</Grid.RowDefinitions>
153157
<Border Background="Transparent"
154-
BorderBrush="{DynamicResource MaterialDesignShadowBrush}"
155-
BorderThickness="1"
156-
CornerRadius="2">
158+
BorderBrush="{DynamicResource MaterialDesignShadowBrush}"
159+
BorderThickness="1"
160+
CornerRadius="2">
157161
<Border.Effect>
158162
<BlurEffect Radius="6"/>
159163
</Border.Effect>
@@ -164,15 +168,17 @@
164168
<RowDefinition Height="*"/>
165169
<RowDefinition Height="Auto"/>
166170
</Grid.RowDefinitions>
167-
<Rectangle Grid.Row="0"
168-
Fill="{DynamicResource MaterialDesignPaper}"
171+
<Border Grid.Row="0"
172+
CornerRadius="2 2 0 0"
173+
Background="{Binding ElementName=templateRoot, Path=Background}"
169174
Height="{StaticResource PopupTopBottomMargin}"/>
170175

171176
<ContentPresenter Grid.Row="1"/>
172177

173-
<Rectangle Grid.Row="2"
174-
Height="{StaticResource PopupTopBottomMargin}"
175-
Fill="{DynamicResource MaterialDesignPaper}" />
178+
<Border Grid.Row="2"
179+
CornerRadius="0 0 2 2"
180+
Height="{StaticResource PopupTopBottomMargin}"
181+
Background="{Binding ElementName=templateRoot, Path=Background}" />
176182
</Grid>
177183
</Grid>
178184
</ControlTemplate>
@@ -387,6 +393,7 @@
387393

388394
<ControlTemplate x:Key="MaterialDesignFloatingHintComboBoxTemplate" TargetType="{x:Type ComboBox}">
389395
<Grid x:Name="templateRoot"
396+
Background="{TemplateBinding Background}"
390397
SnapsToDevicePixels="True">
391398
<Grid x:Name="InnerRoot">
392399
<Grid.ColumnDefinitions>
@@ -432,7 +439,7 @@
432439
<wpf:ComboBoxPopup x:Name="PART_Popup"
433440
AllowsTransparency="true"
434441
Focusable="False"
435-
HorizontalOffset="-11"
442+
HorizontalOffset="-11.5"
436443
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
437444
PlacementTarget="{Binding ElementName=templateRoot}"
438445
SnapsToDevicePixels="True"
@@ -441,14 +448,14 @@
441448
PopupAnimation="Fade"
442449
VerticalOffset="0"
443450
DefaultVerticalOffset="5"
444-
DownVerticalOffset="-27"
451+
DownVerticalOffset="-15.5"
445452
UpVerticalOffset="15"
446453
UpContentTemplate="{StaticResource PopupContentUpTemplate}"
447454
DownContentTemplate="{StaticResource PopupContentDownTemplate}"
448455
DefaultContentTemplate="{StaticResource PopupContentDefaultTemplate}">
449456
<ContentControl>
450-
<ScrollViewer Background="{DynamicResource MaterialDesignPaper}"
451-
MaxHeight="{TemplateBinding MaxDropDownHeight}">
457+
<ScrollViewer MaxHeight="{TemplateBinding MaxDropDownHeight}"
458+
Background="{TemplateBinding Background}">
452459
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" />
453460
</ScrollViewer>
454461
</ContentControl>
@@ -465,7 +472,7 @@
465472
<Setter TargetName="contentPresenter" Property="Visibility" Value="Collapsed" />
466473
</Trigger>
467474
<Trigger Property="wpf:HintAssist.IsFloating" Value="True">
468-
<Setter TargetName="InnerRoot" Property="Margin" Value="0 12 0 0" />
475+
<Setter TargetName="InnerRoot" Property="Margin" Value="0 11.5 0 0" />
469476
</Trigger>
470477
<MultiTrigger>
471478
<MultiTrigger.Conditions>
@@ -511,7 +518,7 @@
511518

512519
<Style x:Key="MaterialDesignComboBox" TargetType="{x:Type ComboBox}">
513520
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
514-
<Setter Property="Background" Value="Transparent"/>
521+
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}"/>
515522
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignTextBoxBorder}"/>
516523
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
517524
<Setter Property="BorderThickness" Value="0 0 0 1"/>

0 commit comments

Comments
 (0)