检查可见行的WPF的DataGrid [英] Check visible rows in a WPF DataGrid

查看:281
本文介绍了检查可见行的WPF的DataGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF 的DataGrid ,其中当有太多的行以查看它得到一个垂直滚动条在屏幕上。如果有办法知道顶部可见行是当用户滚动我想知道的是。

I have a WPF DataGrid, which when there are too many rows to view on the screen it gets a vertical scrollbar. What I would like to know is if there is a way to know what the top visible row is when the user is scrolling.

在理想情况下,我想能够要连接一个事件要知道,当用户滚动和滚动,检查顶部可见行是为了更新一些信息是什么。

Ideally I would like to be able to wire up an event to know when the user is scrolling and on scroll, check what the top visible row is in order to update some information.

推荐答案

使用下面的方法为我工作:

Using the following method worked for me:

// mHorizontalScrollBar is the HorizontalScrollBar subclass control's instance

// Get the total item count
nTotalCount = DataGrid1.Items.Count; 

// Get the first visible row index 
nFirstVisibleRow = mHorizontalScrollBar.Value;

// Get the last visible row index
nLastVisibleRow = nFirstVisibleRow + nTotalCount - mHorizontalScrollBar.Maximum;

这篇关于检查可见行的WPF的DataGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆