Skip to content

Commit e73de72

Browse files
committed
DataGrid ComboBox
1 parent 421783b commit e73de72

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,21 @@
152152
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
153153
</Grid.ColumnDefinitions>
154154
<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">
155-
<Border x:Name="shadow" Background="{DynamicResource MaterialDesignPaper}" CornerRadius="2"
156-
MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
157-
BorderThickness="1" BorderBrush="{DynamicResource MaterialDesignDivider}" Effect="{DynamicResource MaterialDesignShadowDepth2}">
158-
<Border x:Name="dropDownBorder" Background="Transparent">
155+
<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" UseLayoutRounding="True">
156+
<Border x:Name="shadow" Background="{DynamicResource MaterialDesignPaper}" CornerRadius="2" BorderThickness="1"
157+
Effect="{DynamicResource MaterialDesignShadowDepth2}" />
158+
<Border x:Name="dropDownBorder" Margin="{Binding ElementName=shadow, Path=Margin, Mode=OneWay}" Background="Transparent"
159+
CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource MaterialDesignDivider}">
159160
<ScrollViewer x:Name="DropDownScrollViewer">
160161
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
161162
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
162163
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
163164
</Canvas>
164-
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
165-
/>
165+
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" UseLayoutRounding="False" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
166166
</Grid>
167167
</ScrollViewer>
168168
</Border>
169-
</Border>
169+
</Grid>
170170
</Popup>
171171
<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 MaterialDesignDataGridComboBoxToggleButton}"
172172
/>
@@ -230,18 +230,21 @@
230230
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
231231
</Grid.ColumnDefinitions>
232232
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
233-
<Border x:Name="dropDownBorder" BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="1" Background="{DynamicResource MaterialDesignPaper}"
234-
CornerRadius="2"
235-
MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" Effect="{DynamicResource MaterialDesignShadowDepth2}">
236-
<ScrollViewer x:Name="DropDownScrollViewer">
237-
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
238-
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
239-
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
240-
</Canvas>
241-
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
242-
</Grid>
243-
</ScrollViewer>
244-
</Border>
233+
<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" UseLayoutRounding="True">
234+
<Border x:Name="shadow" Background="{DynamicResource MaterialDesignPaper}" CornerRadius="2" BorderThickness="1"
235+
Effect="{DynamicResource MaterialDesignShadowDepth2}" />
236+
<Border x:Name="dropDownBorder" Margin="{Binding ElementName=shadow, Path=Margin, Mode=OneWay}" Background="Transparent"
237+
CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource MaterialDesignDivider}">
238+
<ScrollViewer x:Name="DropDownScrollViewer">
239+
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
240+
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
241+
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
242+
</Canvas>
243+
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" UseLayoutRounding="False" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
244+
</Grid>
245+
</ScrollViewer>
246+
</Border>
247+
</Grid>
245248
</Popup>
246249
<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 MaterialDesignDataGridComboBoxToggleButton}"/>
247250
<Border x:Name="border" Background="Transparent" Margin="{TemplateBinding BorderThickness}">
@@ -260,7 +263,7 @@
260263
</Grid>
261264
<ControlTemplate.Triggers>
262265
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
263-
<Setter Property="Margin" TargetName="dropDownBorder" Value="5,5,5,5"/>
266+
<Setter Property="Margin" TargetName="shadow" Value="5,5,5,5"/>
264267
</Trigger>
265268
<Trigger Property="IsEnabled" Value="false">
266269
<Setter Property="Opacity" TargetName="border" Value="0.56"/>

0 commit comments

Comments
 (0)