Skip to content

Commit 65718d6

Browse files
committed
fix: replace ComboBox ControlTemplate with transparent ToggleButton to fix white-on-white dropdown in dark theme
1 parent c80e8b1 commit 65718d6

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

‎Resources/Styles.xaml‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,88 @@
2424
<Setter Property="FontSize" Value="13"/>
2525
</Style>
2626

27+
<Style TargetType="ComboBoxItem">
28+
<Setter Property="Background" Value="{StaticResource Surface}"/>
29+
<Setter Property="Foreground" Value="{StaticResource TextPrimary}"/>
30+
<Setter Property="Padding" Value="10,6"/>
31+
<Setter Property="FontSize" Value="13"/>
32+
<Style.Triggers>
33+
<Trigger Property="IsHighlighted" Value="True">
34+
<Setter Property="Background" Value="{StaticResource SurfaceLift}"/>
35+
<Setter Property="Foreground" Value="{StaticResource TextPrimary}"/>
36+
</Trigger>
37+
</Style.Triggers>
38+
</Style>
39+
40+
<ControlTemplate x:Key="ComboBoxToggleTemplate" TargetType="ToggleButton">
41+
<Border Background="Transparent"/>
42+
</ControlTemplate>
43+
2744
<Style TargetType="ComboBox">
2845
<Setter Property="Background" Value="{StaticResource Surface}"/>
2946
<Setter Property="Foreground" Value="{StaticResource TextPrimary}"/>
3047
<Setter Property="BorderBrush" Value="{StaticResource Border}"/>
3148
<Setter Property="BorderThickness" Value="1"/>
3249
<Setter Property="Padding" Value="8,6"/>
3350
<Setter Property="FontSize" Value="13"/>
51+
<Setter Property="Template">
52+
<Setter.Value>
53+
<ControlTemplate TargetType="ComboBox">
54+
<Grid>
55+
<Border x:Name="border"
56+
Background="{TemplateBinding Background}"
57+
BorderBrush="{TemplateBinding BorderBrush}"
58+
BorderThickness="{TemplateBinding BorderThickness}"
59+
CornerRadius="6">
60+
<Grid>
61+
<Grid.ColumnDefinitions>
62+
<ColumnDefinition Width="*"/>
63+
<ColumnDefinition Width="24"/>
64+
</Grid.ColumnDefinitions>
65+
<ContentPresenter Grid.Column="0"
66+
Content="{TemplateBinding SelectionBoxItem}"
67+
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
68+
Margin="{TemplateBinding Padding}"
69+
VerticalAlignment="Center"
70+
IsHitTestVisible="False"/>
71+
<Path Grid.Column="1"
72+
Data="M 0 0 L 4 4 L 8 0 Z"
73+
Fill="{StaticResource TextMuted}"
74+
HorizontalAlignment="Center"
75+
VerticalAlignment="Center"
76+
IsHitTestVisible="False"/>
77+
<ToggleButton Grid.ColumnSpan="2"
78+
Template="{StaticResource ComboBoxToggleTemplate}"
79+
Focusable="False"
80+
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
81+
ClickMode="Press"/>
82+
</Grid>
83+
</Border>
84+
<Popup Placement="Bottom"
85+
IsOpen="{TemplateBinding IsDropDownOpen}"
86+
AllowsTransparency="True"
87+
Focusable="False"
88+
PopupAnimation="Slide">
89+
<Border Background="{StaticResource Surface}"
90+
BorderBrush="{StaticResource Border}"
91+
BorderThickness="1"
92+
CornerRadius="6"
93+
MinWidth="{TemplateBinding ActualWidth}"
94+
MaxHeight="{TemplateBinding MaxDropDownHeight}">
95+
<ScrollViewer>
96+
<ItemsPresenter/>
97+
</ScrollViewer>
98+
</Border>
99+
</Popup>
100+
</Grid>
101+
<ControlTemplate.Triggers>
102+
<Trigger Property="IsMouseOver" Value="True">
103+
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource AccentBorder}"/>
104+
</Trigger>
105+
</ControlTemplate.Triggers>
106+
</ControlTemplate>
107+
</Setter.Value>
108+
</Setter>
34109
</Style>
35110

36111
<Style TargetType="ListBox">

0 commit comments

Comments
 (0)