diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml
index eb43db54f6..5746b3ddd4 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml
@@ -534,7 +534,7 @@
PopupAnimation="Fade"
RelativeHorizontalOffset="-6"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
- Tag="{DynamicResource MaterialDesign.Brush.Background}"
+ Tag="{DynamicResource MaterialDesign.Brush.ComboBox.DropDown.Background}"
UpVerticalOffset="15"
UseLayoutRounding="{TemplateBinding UseLayoutRounding}"
VerticalOffset="0">
@@ -557,7 +557,7 @@
+ Background="Transparent">
@@ -796,8 +796,8 @@
-
-
+
+
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Dark.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Dark.xaml
index c0f104b5c7..ddc770bd20 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Dark.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Dark.xaml
@@ -28,6 +28,7 @@
+
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml
index 49840244c0..45e5533fe3 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml
@@ -159,7 +159,7 @@
@@ -167,7 +167,7 @@
@@ -285,7 +285,7 @@
@@ -293,7 +293,7 @@
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Light.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Light.xaml
index 68dac171db..8f00d024f1 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Light.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Light.xaml
@@ -28,6 +28,7 @@
+
diff --git a/src/MaterialDesignToolkit.ResourceGeneration/ThemeColors.json b/src/MaterialDesignToolkit.ResourceGeneration/ThemeColors.json
index 9f8172bd23..f3db724322 100644
--- a/src/MaterialDesignToolkit.ResourceGeneration/ThemeColors.json
+++ b/src/MaterialDesignToolkit.ResourceGeneration/ThemeColors.json
@@ -246,6 +246,15 @@
},
"alternateKeys": []
},
+ {
+ "name": "MaterialDesign.Brush.ComboBox.DropDown.Background",
+ "themeValues": {
+ "light": "Neutral900",
+ "dark": "Neutral100"
+ },
+ "alternateKeys": [],
+ "obsoleteKeys": []
+ },
{
"name": "MaterialDesign.Brush.ComboBox.Popup.DarkBackground",
"themeValues": {
diff --git a/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs
index e8e423c231..d74644be00 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.Windows.Media;
using MaterialDesignThemes.UITests.WPF.TextBoxes;
namespace MaterialDesignThemes.UITests.WPF.ComboBoxes;
@@ -269,4 +270,36 @@ public async Task ComboBox_BorderShouldDependOnAppliedStyle(string style, double
Thickness thickness = await border.GetBorderThickness();
await Assert.That(thickness).IsEqualTo(new Thickness(left, top, right, bottom));
}
+
+ [Test]
+ [Description("Issue 3887")]
+ public async Task ComboBox_UsesDropDownBackgroundResource_WhenBackgroundIsNotSet()
+ {
+ await using var recorder = new TestRecorder(App);
+
+ var stackPanel = await LoadXaml($$"""
+
+
+
+
+
+
+
+
+
+
+ """);
+
+ var comboBox = await stackPanel.GetElement();
+ await comboBox.LeftClick(Position.RightCenter);
+
+ var popup = await Wait.For(async () => await comboBox.GetElement("PART_Popup"));
+ Color? popupBackground = await popup.GetBackgroundColor();
+
+ await Assert.That(popupBackground).IsNotNull();
+ await Assert.That(popupBackground).IsEqualTo((Color)ColorConverter.ConvertFromString("#CC336699"));
+
+ recorder.Success();
+ }
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.g.cs b/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.g.cs
index b7063d9a20..498b8ffff3 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.g.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.g.cs
@@ -53,6 +53,7 @@ private partial string GetXamlWrapPanel()
+
@@ -345,6 +346,11 @@ private partial async Task AssertAllThemeBrushesSet(IVisualElement pa
Color? textBlockBackground = await textBlock.GetBackgroundColor();
await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.OutlineBorder"));
}
+ {
+ IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.DropDown.Background\"]");
+ Color? textBlockBackground = await textBlock.GetBackgroundColor();
+ await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.DropDown.Background"));
+ }
{
IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.Popup.DarkBackground\"]");
Color? textBlockBackground = await textBlock.GetBackgroundColor();
@@ -955,6 +961,7 @@ private static IEnumerable GetBrushResourceNames()
yield return "MaterialDesign.Brush.ComboBox.HoverBorder";
yield return "MaterialDesign.Brush.ComboBox.Border";
yield return "MaterialDesign.Brush.ComboBox.OutlineBorder";
+ yield return "MaterialDesign.Brush.ComboBox.DropDown.Background";
yield return "MaterialDesign.Brush.ComboBox.Popup.DarkBackground";
yield return "MaterialDesign.Brush.ComboBox.Popup.DarkForeground";
yield return "MaterialDesign.Brush.ComboBox.Popup.LightBackground";