Skip to content

Commit fe81676

Browse files
Fix for wrong outline border on ComboBox (#3625)
* Add failing test * Fix issue by conditionally chaning the border thickness
1 parent c2fe015 commit fe81676

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,11 @@
775775
</MultiTrigger>
776776

777777
<!-- PART_Popup.IsOpen -->
778-
<Trigger SourceName="PART_Popup" Property="IsOpen" Value="True">
778+
<MultiTrigger>
779+
<MultiTrigger.Conditions>
780+
<Condition SourceName="PART_Popup" Property="IsOpen" Value="True" />
781+
<Condition Property="wpf:TextFieldAssist.HasOutlinedTextField" Value="True" />
782+
</MultiTrigger.Conditions>
779783
<Setter TargetName="OuterBorder" Property="BorderThickness" Value="{Binding Path=(wpf:TextFieldAssist.OutlinedBorderActiveThickness), RelativeSource={RelativeSource TemplatedParent}}" />
780784
<Setter TargetName="ContentGrid" Property="Margin">
781785
<Setter.Value>
@@ -785,7 +789,7 @@
785789
</MultiBinding>
786790
</Setter.Value>
787791
</Setter>
788-
</Trigger>
792+
</MultiTrigger>
789793
<MultiTrigger>
790794
<MultiTrigger.Conditions>
791795
<Condition SourceName="PART_Popup" Property="IsOpen" Value="True" />

tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,31 @@ public async Task ComboBox_WithHorizontalContentAlignment_RespectsAlignment(Hori
282282

283283
recorder.Success();
284284
}
285+
286+
[Theory]
287+
[InlineData("MaterialDesignFloatingHintComboBox", 0, 0, 0, 1)]
288+
[InlineData("MaterialDesignFilledComboBox", 0, 0, 0, 1)]
289+
[InlineData("MaterialDesignOutlinedComboBox", 2, 2, 2, 2)]
290+
[Description("Issue 3623")]
291+
public async Task ComboBox_BorderShouldDependOnAppliedStyle(string style, double left, double top, double right, double bottom)
292+
{
293+
await using var recorder = new TestRecorder(App);
294+
295+
var stackPanel = await LoadXaml<StackPanel>($$"""
296+
<StackPanel>
297+
<ComboBox Style="{StaticResource {{style}}}">
298+
<ComboBoxItem Content="TEST" IsSelected="True" />
299+
</ComboBox>
300+
</StackPanel>
301+
""");
302+
var comboBox = await stackPanel.GetElement<ComboBox>("/ComboBox");
303+
var border = await comboBox.GetElement<Border>("OuterBorder");
304+
305+
await comboBox.LeftClick();
306+
307+
Thickness thickness = await border.GetBorderThickness();
308+
Assert.Equal(new Thickness(left, top, right, bottom), thickness);
309+
310+
recorder.Success();
311+
}
285312
}

0 commit comments

Comments
 (0)