WPF
为什么放大时 ScrollViewer 上的 ScrollBar 未激活?
<Window x:Class="WpfApplication4.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="356" Width="804">
<Grid>
<ScrollViewer
PreviewMouseWheel="ScrollViewer_PreviewMouseWheel"
VerticalScrollBarVisibility="Visible"
HorizontalScrollBarVisibility="Visible">
<Canvas>
<Canvas.LayoutTransform>
<TransformGroup>
<ScaleTransform x:Name="scaleTransform"/>
</TransformGroup>
</Canvas.LayoutTransform>
<TextBlock Canvas.Left="34" Canvas.Top="47" Name="textBlock1" Text="TK QSDFWPO Aàâéèêëîïôùûüÿçæœ; BLA BLA BLA...... " />
<TextBlock Canvas.Left="310" Canvas.Top="46" Name="textBlock4" Text="TK QSDFWPO Aàâéèêëîïôùûüÿçæœ; BLA BLA BLA...... " />
<TextBlock Canvas.Left="188" Canvas.Top="157" Name="textBlock11" Text="TK QSDFWPO Aàâéèêëîïôùûüÿçæœ; BLA BLA BLA...... " />
</Canvas>
</ScrollViewer>
</Grid>
</Window>
CS:
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.Delta > 0)
scaleTransform.ScaleY =
scaleTransform.ScaleX += 0.1;
else
scaleTransform.ScaleY =
scaleTransform.ScaleX -= 0.1;
}
为什么放大时没有激活 ScrollBar?