ScrollViewer wpf - 不起作用
我有一个 wpf 应用程序。 在窗口中,我有一个 TextBlock,其中包含很多数字,每个数字都在其行中。我希望滚动查看器在需要时出现。它不起作用...这是代码
<ScrollViewer CanContentScroll="True" Margin="5,25,5,0" Grid.Row="2" HorizontalScrollBarVisibility="Auto" >
<TextBlock MaxHeight="500" Height="Auto" Width="Auto" VerticalAlignment="Top" Name="TextBlock_Results"/>
</ScrollViewer>
I have a wpf application.
In the window i have a TextBlock which contains a lot of numbers , each number in it's row. I want the scrollViewer to appear when needed. It doesn't work... here is the code
<ScrollViewer CanContentScroll="True" Margin="5,25,5,0" Grid.Row="2" HorizontalScrollBarVisibility="Auto" >
<TextBlock MaxHeight="500" Height="Auto" Width="Auto" VerticalAlignment="Top" Name="TextBlock_Results"/>
</ScrollViewer>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,滚动查看器中的文本块无法滚动。要使 ScrollViewer 能够执行基于像素的滚动,您需要将 can 内容滚动设置为 false。
两个滚动条的可见性是独立控制的。我已将垂直滚动条隐藏在下面的一个中。
The text block in the scroll viewer is not capable of scrolling by default. To enable the ScrollViewer to perform pixel based scrolling you need to set the can content scroll to false.
The visibillity of the two scroll bars are controlled independently. I have hidden the vertical scroll bar in the one bellow.