fix: update ScrollViewer styles for improved scrollbar behavior

This commit is contained in:
Dong Bin
2025-04-03 19:36:01 +08:00
parent 45b1c9ab73
commit b90b606b97
2 changed files with 13 additions and 11 deletions

View File

@@ -39,13 +39,7 @@
<ControlTheme x:Key="{x:Type ScrollBar}" TargetType="ScrollBar">
<Setter Property="Cursor" Value="Arrow" />
<Setter Property="Transitions">
<Transitions>
<DoubleTransition Property="Width" Duration="0:0:0.1" />
<DoubleTransition Property="Height" Duration="0:0:0.1" />
<!--<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.1" />-->
</Transitions>
</Setter>
<Setter Property="ShowDelay" Value="0" />
<Style Selector="^:horizontal">
<Setter Property="Height" Value="{StaticResource ScrollBarThickness}" />
<Setter Property="Template">
@@ -187,6 +181,13 @@
</Setter>
</Style>
<Style Selector="^ /template/ Thumb#thumb">
<Setter Property="Transitions">
<Transitions>
<DoubleTransition Property="Width" Duration="0:0:0.1" />
<DoubleTransition Property="Height" Duration="0:0:0.1" />
<!--<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.1" />-->
</Transitions>
</Setter>
<Setter Property="Foreground" Value="{DynamicResource ScrollBarThumbForeground}" />
<Setter Property="Template">
<ControlTemplate TargetType="Thumb">
@@ -201,11 +202,11 @@
<Setter Property="Foreground" Value="{DynamicResource ScrollBarThumbPointeroverForeground}" />
</Style>
<Style Selector="^:horizontal /template/ Thumb#thumb">
<Setter Property="MinWidth" Value="{DynamicResource ScrollBarThickness}" />
<Setter Property="MinWidth" Value="{DynamicResource ScrollBarMinLength}" />
<Setter Property="Height" Value="{DynamicResource ScrollBarThumbThickness}" />
</Style>
<Style Selector="^:vertical /template/ Thumb#thumb">
<Setter Property="MinHeight" Value="{DynamicResource ScrollBarThickness}" />
<Setter Property="MinHeight" Value="{DynamicResource ScrollBarMinLength}" />
<Setter Property="Width" Value="{DynamicResource ScrollBarThumbThickness}" />
</Style>
<Style Selector="^ /template/ RepeatButton > PathIcon">
@@ -222,10 +223,10 @@
<Style Selector="^ /template/ RepeatButton">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^:vertical">
<Style Selector="^:vertical /template/ Thumb#thumb">
<Setter Property="Width" Value="2" />
</Style>
<Style Selector="^:horizontal">
<Style Selector="^:horizontal /template/ Thumb#thumb">
<Setter Property="Height" Value="2" />
</Style>
</Style>

View File

@@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StaticResource x:Key="ScrollBarThickness" ResourceKey="SemiSpacingTight" />
<x:Double x:Key="ScrollBarMinLength">24</x:Double>
<StaticResource x:Key="ScrollBarThumbThickness" ResourceKey="SemiSpacingTight" />
<StaticResource x:Key="ScrollBarThumbCornerRadius" ResourceKey="SemiBorderRadiusMedium" />
<StaticResource x:Key="ScrollBarUpGlyph" ResourceKey="SemiIconSmallTriangleTop" />