我正在尝试检测用户何时开始在xceed网格控件中向下滚动。我想知道滚动条的位置是什么,以及当前在屏幕上显示哪些行(索引就足够了)。
我有什么想法可以做到这一点?
答案 0 :(得分:1)
对于基于项目滚动的DataGrid
,请尝试此
private void DataGrid_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
var datagrid = sender as DataGrid;
var view = CollectionViewSource.GetDefaultView(datagrid.ItemsSource) as CollectionView;
if (view != null && view.Count > 0)
{
int firstIndex = (int)e.VerticalOffset;
var firstItem = view.GetItemAt(firstIndex);
int lastIndex = Math.Min(view.Count - 1, (int)(e.VerticalOffset + e.ViewportHeight));
var lastItem = view.GetItemAt(lastIndex);
}
}