ScrollViewer
ScrollViewer是一带有ScrollBar的区域,它内部可以放置控件,当这些控件的布局超出它的边界时,就会出现滚动条。
在CS代码中,LineUp是移动一点,而PageUp是移动一个页面。
XAML代码:
<Grid>
<Border BorderBrush="Black" Background="White" BorderThickness="2" Height="520" Width="520" VerticalAlignment="Top">
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto" Name="sv1">
<TextBlock TextWrapping="Wrap" Width="800" Height="1000" Name="txt1"/>
</ScrollViewer>
</Border>
<StackPanel DockPanel.Dock="Left" Margin="117,40,225.686666666667,0" Height="207.64" VerticalAlignment="Top">
<Button Margin="3,0,0,2" Background="White" Click="svLineUp">Adjust Line Up</Button>
<Button Margin="3,0,0,2" Background="White" Click="svLineDown">Adjust Line Down</Button>
<Button Margin="3,0,0,2" Background="White" Click="svLineRight">Adjust Line Right</Button>
<Button Margin="3,0,0,2" Background="White" Click="svLineLeft">Adjust Line Left</Button>
<Button Margin="3,0,0,2" Background="White" Click="svPageUp">Adjust Page Up</Button>
<Button Margin="3,0,0,2" Background="White" Click="svPageDown">Adjust Page Down</Button>
<Button Margin="3,0,0,2" Background="White" Click="svPageRight">Adjust Page Right</Button>
<Button Margin="3,0,0,2" Background="White" Click="svPageLeft">Adjust Page Left</Button>
<TextBlock Name="txt2" TextWrapping="Wrap"/>
</StackPanel>
</Grid>
CS代码:
private void svLineUp(object sender, RoutedEventArgs e)
{
sv1.LineUp();
}
private void svLineDown(object sender, RoutedEventArgs e)
{
sv1.LineDown();
}
private void svLineRight(object sender, RoutedEventArgs e)
{
sv1.LineRight();
}
private void svLineLeft(object sender, RoutedEventArgs e)
{
sv1.LineLeft();
}
private void svPageUp(object sender, RoutedEventArgs e)
{
sv1.PageUp();
}
private void svPageDown(object sender, RoutedEventArgs e)
{
sv1.PageDown();
}
private void svPageRight(object sender, RoutedEventArgs e)
{
sv1.PageRight();
}
private void svPageLeft(object sender, RoutedEventArgs e)
{
sv1.PageLeft();
}
本文参考MSDN组织
《asp.net core精要讲解》 https://ke.qq.com/course/265696
《asp.net core 3.0》 https://ke.qq.com/course/437517
《asp.net core项目实战》 https://ke.qq.com/course/291868
《基于.net core微服务》 https://ke.qq.com/course/299524