将滚动查看器设置为自动滚动到底部



我使用mytoolkit.extended控件用于datagrid,有datagrid,其中有mtlistbox。我已经将垂直滚动条设置为自动,它工作正常,但是我需要一个选项,每当滚动栏出现时,它都应该下降并显示最后一个项目。

ScrollViewer具有一个属性,该属性指示可以滚动的区域的垂直大小,称为 ScrollableHeight

要更改ScrollViewer中的偏移位置,您应该使用ChangeView方法,这会导致ScrollViewer根据指定的偏移和变焦因子加载新视图。

公共bool changeview(无效的水平offset, 可无效的垂直offsods,无效的zoomfactor(

现在您可以像这样简单地使用它:

myScrollViewer.ChangeView(null, myScrollViewer.ScrollableHeight, null);

您将要确保在UI线程上执行此操作,并因此可以将工作派遣到UI线程:

await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
    myScrollViewer.ChangeView(null, myScrollViewer.ScrollableHeight, null);
});

最新更新