fix: update ComboBox popup behavior and style when scrollbar is visible (#865)

This commit is contained in:
Jeffrey
2026-10-25 02:05:35 +01:00
committed by GitHub
parent 2a03c7a5d5
commit 74648cbe26
+47 -39
View File
@@ -244,6 +244,45 @@
<Setter Property="Margin" Value="0,0,0,8"/> <Setter Property="Margin" Value="0,0,0,8"/>
</Style> </Style>
<!-- ScrollBar Style -->
<Style x:Key="AppScrollBarStyle" TargetType="{x:Type ScrollBar}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Width" Value="8"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollBar}">
<Grid>
<Track Name="PART_Track" IsDirectionReversed="true">
<Track.Thumb>
<Thumb>
<Thumb.Style>
<Style TargetType="Thumb">
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbColor}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Thumb">
<Border Background="{TemplateBinding Background}" CornerRadius="4"/>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbHoverColor}"/>
</Trigger>
</Style.Triggers>
</Style>
</Thumb.Style>
</Thumb>
</Track.Thumb>
</Track>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource AppScrollBarStyle}"/>
<!-- Shared ComboBox style used across windows --> <!-- Shared ComboBox style used across windows -->
<Style TargetType="ComboBoxItem"> <Style TargetType="ComboBoxItem">
<Setter Property="Foreground" Value="{DynamicResource AppFgColor}"/> <Setter Property="Foreground" Value="{DynamicResource AppFgColor}"/>
@@ -365,13 +404,13 @@
Content="{TemplateBinding SelectionBoxItem}" Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"/> ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"/>
<Popup x:Name="Popup" <Popup x:Name="PART_Popup"
Placement="Bottom" Placement="Bottom"
IsOpen="{TemplateBinding IsDropDownOpen}" IsOpen="{TemplateBinding IsDropDownOpen}"
AllowsTransparency="True" AllowsTransparency="True"
Focusable="False" Focusable="False"
PopupAnimation="Fade" PopupAnimation="Fade"
StaysOpen="False" StaysOpen="True"
PlacementTarget="{Binding ElementName=ToggleButton}" PlacementTarget="{Binding ElementName=ToggleButton}"
VerticalOffset="1" VerticalOffset="1"
HorizontalOffset="0"> HorizontalOffset="0">
@@ -386,8 +425,14 @@
<DropShadowEffect BlurRadius="12" Opacity="0.25" ShadowDepth="4"/> <DropShadowEffect BlurRadius="12" Opacity="0.25" ShadowDepth="4"/>
</Border.Effect> </Border.Effect>
<ScrollViewer Margin="0,2,0,0" <ScrollViewer Margin="0,2,0,0"
CanContentScroll="False"
VerticalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"> HorizontalScrollBarVisibility="Disabled">
<ScrollViewer.Resources>
<Style TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource AppScrollBarStyle}">
<Setter Property="Margin" Value="0,0,0,5"/>
</Style>
</ScrollViewer.Resources>
<ItemsPresenter Margin="0,0,0,1"/> <ItemsPresenter Margin="0,0,0,1"/>
</ScrollViewer> </ScrollViewer>
</Border> </Border>
@@ -553,43 +598,6 @@
<Setter Property="Margin" Value="8,4"/> <Setter Property="Margin" Value="8,4"/>
</Style> </Style>
<!-- ScrollBar Style -->
<Style TargetType="{x:Type ScrollBar}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Width" Value="8"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollBar}">
<Grid>
<Track Name="PART_Track" IsDirectionReversed="true">
<Track.Thumb>
<Thumb>
<Thumb.Style>
<Style TargetType="Thumb">
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbColor}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Thumb">
<Border Background="{TemplateBinding Background}" CornerRadius="4"/>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbHoverColor}"/>
</Trigger>
</Style.Triggers>
</Style>
</Thumb.Style>
</Thumb>
</Track.Thumb>
</Track>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- TextBox outer border: side/top borders in side color, background with hover/focus states --> <!-- TextBox outer border: side/top borders in side color, background with hover/focus states -->
<Style x:Key="TextBoxBorderStyle" TargetType="Border"> <Style x:Key="TextBoxBorderStyle" TargetType="Border">
<Setter Property="Background" Value="{DynamicResource TextBoxBgColor}"/> <Setter Property="Background" Value="{DynamicResource TextBoxBgColor}"/>