Skip to content

Commit 421783b

Browse files
committed
Combobox
1 parent de77629 commit 421783b

File tree

1 file changed

+46
-36
lines changed

1 file changed

+46
-36
lines changed

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,11 @@
158158
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
159159
</Grid.ColumnDefinitions>
160160
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
161-
<Border x:Name="shadow" Background="{DynamicResource MaterialDesignPaper}" CornerRadius="2"
162-
MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
163-
BorderThickness="1" BorderBrush="{DynamicResource MaterialDesignDivider}" Effect="{StaticResource MaterialDesignShadowDepth2}">
164-
<Border x:Name="dropDownBorder" Background="Transparent">
161+
<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" >
162+
<Border x:Name="shadow" Background="{DynamicResource MaterialDesignPaper}" CornerRadius="2"
163+
Effect="{StaticResource MaterialDesignShadowDepth2}" />
164+
<Border x:Name="dropDownBorder" Margin="{Binding ElementName=shadow, Path=Margin, Mode=OneWay}" Background="Transparent"
165+
CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource MaterialDesignDivider}">
165166
<ScrollViewer x:Name="DropDownScrollViewer">
166167
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
167168
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
@@ -172,7 +173,7 @@
172173
</Grid>
173174
</ScrollViewer>
174175
</Border>
175-
</Border>
176+
</Grid>
176177
</Popup>
177178
<ToggleButton x:Name="toggleButton" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource MaterialDesignComboBoxToggleButton}"
178179
/>
@@ -261,10 +262,11 @@
261262
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
262263
</Grid.ColumnDefinitions>
263264
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
264-
<Border x:Name="shadow" Background="{DynamicResource MaterialDesignPaper}" CornerRadius="2"
265-
MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
266-
BorderThickness="1" BorderBrush="{DynamicResource MaterialDesignDivider}" Effect="{StaticResource MaterialDesignShadowDepth2}">
267-
<Border x:Name="dropDownBorder" Background="Transparent">
265+
<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
266+
<Border x:Name="shadow" Background="{DynamicResource MaterialDesignPaper}" CornerRadius="2"
267+
Effect="{StaticResource MaterialDesignShadowDepth2}" />
268+
<Border x:Name="dropDownBorder" Margin="{Binding ElementName=shadow, Path=Margin, Mode=OneWay}" Background="Transparent"
269+
CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource MaterialDesignDivider}">
268270
<ScrollViewer x:Name="DropDownScrollViewer">
269271
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
270272
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
@@ -275,7 +277,7 @@
275277
</Grid>
276278
</ScrollViewer>
277279
</Border>
278-
</Border>
280+
</Grid>
279281
</Popup>
280282
<ToggleButton x:Name="toggleButton" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource MaterialDesignComboBoxToggleButton}"
281283
/>
@@ -356,18 +358,22 @@
356358
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
357359
</Grid.ColumnDefinitions>
358360
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
359-
<Border x:Name="dropDownBorder" BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="1" Background="{DynamicResource MaterialDesignPaper}"
360-
CornerRadius="2"
361-
MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" Effect="{StaticResource MaterialDesignShadowDepth2}">
362-
<ScrollViewer x:Name="DropDownScrollViewer">
363-
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
364-
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
365-
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
366-
</Canvas>
367-
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
368-
</Grid>
369-
</ScrollViewer>
370-
</Border>
361+
<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
362+
<Border x:Name="shadow" Background="{DynamicResource MaterialDesignPaper}" CornerRadius="2"
363+
Effect="{StaticResource MaterialDesignShadowDepth2}" />
364+
<Border x:Name="dropDownBorder" Margin="{Binding ElementName=shadow, Path=Margin, Mode=OneWay}" Background="Transparent"
365+
CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource MaterialDesignDivider}">
366+
<ScrollViewer x:Name="DropDownScrollViewer">
367+
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
368+
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
369+
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
370+
</Canvas>
371+
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
372+
/>
373+
</Grid>
374+
</ScrollViewer>
375+
</Border>
376+
</Grid>
371377
</Popup>
372378
<ToggleButton x:Name="toggleButton" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource MaterialDesignComboBoxToggleButton}"/>
373379
<Border x:Name="border" Background="Transparent" Margin="{TemplateBinding BorderThickness}">
@@ -387,7 +393,7 @@
387393
</Grid>
388394
<ControlTemplate.Triggers>
389395
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
390-
<Setter Property="Margin" TargetName="dropDownBorder" Value="5,5,5,5"/>
396+
<Setter Property="Margin" TargetName="shadow" Value="5,5,5,5"/>
391397
</Trigger>
392398
<Trigger Property="IsEnabled" Value="false">
393399
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
@@ -461,18 +467,22 @@
461467
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
462468
</Grid.ColumnDefinitions>
463469
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
464-
<Border x:Name="dropDownBorder" BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="1" Background="{DynamicResource MaterialDesignPaper}"
465-
CornerRadius="2"
466-
MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" Effect="{StaticResource MaterialDesignShadowDepth2}">
467-
<ScrollViewer x:Name="DropDownScrollViewer">
468-
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
469-
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
470-
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
471-
</Canvas>
472-
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
473-
</Grid>
474-
</ScrollViewer>
475-
</Border>
470+
<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
471+
<Border x:Name="shadow" Background="{DynamicResource MaterialDesignPaper}" CornerRadius="2"
472+
Effect="{StaticResource MaterialDesignShadowDepth2}" />
473+
<Border x:Name="dropDownBorder" Margin="{Binding ElementName=shadow, Path=Margin, Mode=OneWay}" Background="Transparent"
474+
CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource MaterialDesignDivider}">
475+
<ScrollViewer x:Name="DropDownScrollViewer">
476+
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
477+
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
478+
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
479+
</Canvas>
480+
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
481+
/>
482+
</Grid>
483+
</ScrollViewer>
484+
</Border>
485+
</Grid>
476486
</Popup>
477487
<ToggleButton x:Name="toggleButton" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource MaterialDesignComboBoxToggleButton}"
478488
Margin="0 14 0 0"/>
@@ -512,7 +522,7 @@
512522
<Setter TargetName="Hint" Property="Foreground" Value="{DynamicResource PrimaryHueMidBrush}" />
513523
</MultiTrigger>
514524
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
515-
<Setter Property="Margin" TargetName="dropDownBorder" Value="5,5,5,5"/>
525+
<Setter Property="Margin" TargetName="shadow" Value="5,5,5,5"/>
516526
</Trigger>
517527
<Trigger Property="IsEnabled" Value="false">
518528
<Setter Property="Opacity" TargetName="border" Value="0.56"/>

0 commit comments

Comments
 (0)