下图显示了我的项目。
以下是满足测试需求的XAML代码。
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="200" Width="525">
<ScrollViewer Name="ScrollViewer1" Height="67" VerticalAlignment="Top">
<StackPanel>
<TextBox Name="TextBox1" Text="TextBox1"/>
<TextBox Name="TextBox2" Text="TextBox2"/>
<TextBox Name="TextBox3" Text="TextBox3"/>
<TextBox Name="TextBox4" Text="TextBox4"/>
<TextBox Name="TextBox5" Text="TextBox5"/>
<TextBox Name="TextBox6" Text="TextBox6"/>
</StackPanel>
</ScrollViewer>
</Window>
下图显示了我的问题;
那么,如何点击WPF ScrollViewer向下按钮以结束ScrollViwer?
答案 0 :(得分:1)
右键单击ScrollViewer-&gt;编辑模板 - &gt;编辑副本,以查看Scrollviewer的模板。 ScrollViewer包含一个ScrollBar。 ScrollBar包含RepeatButton和Track。 RepeatButton负责滚动条的上下移动。试试看吧。您可能会对如何实现目标有所了解。
答案 1 :(得分:1)
解决方案可能是订阅该按钮的点击,如https://stackoverflow.com/a/4932118/6890102,然后调用ScrollToEnd()
的{{1}}方法。但可能有更好的解决方案。