Check visible rows in a WPF DataGrid

后端 未结 4 931
伪装坚强ぢ
伪装坚强ぢ 2020-12-19 05:53

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

4条回答
  •  太阳男子
    2020-12-19 06:06

    It's sort of an overcomplicated way of doing it, but it may work. First, subclass DataGridRowsPresenter and override the OnViewportOffsetChanged method. Then, duplicate the standard control template for the datagrid, and replace the DataGridRowsPresenter with your own. I leave the details of hit testing for a row relative to the viewport up to you ;-).

    What are you trying to accomplish, specifically? Maybe we can come up with a better way, as this may be very brittle and requires a bunch of extra work (i.e. keeping the control template in sync if they update it).

提交回复
热议问题