您可以执行以下操作:
<ScrollViewer Name="scrollViewer1"
Grid.Row="1"
Grid.ColumnSpan="2"
VerticalAlignment="Stretch"
VerticalContentAlignment="Stretch"
BorderBrush="{x:Null}"
VerticalScrollBarVisibility="Auto">
<!-- New Bit -->
<ScrollViewer.Style>
<Style TargetType="{x:Type ScrollViewer}">
<Style.Resources>
<Thickness x:Key="InvisScrollBarDimension"
Bottom="0"
Left="0"
Right="{StaticResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
Top="0" />
</Style.Resources>
<Setter Property="Margin"
Value="{StaticResource InvisScrollBarDimension}" />
<Style.Triggers>
<Trigger Property="ComputedVerticalScrollBarVisibility"
Value="Visible">
<Setter Property="Margin"
Value="0" />
</Trigger>
</Style.Triggers>
</Style>
</ScrollViewer.Style>
...
概念几乎是在不可见时根据系统参数赋予ScrollViewer
权限, for帮助我们确定并在可见时将其重置为 0 。Margin
VerticalScrollBarWidthKey
Scrollbar
Trigger
ComputedVerticalScrollBarVisibility
Scrollbar
这应该在运行时产生无抖动效果。