在WPF DataGrid中设置垂直滚动条位置 [英] Setting Vertical Scrollbar position in WPF DataGrid

查看:762
本文介绍了在WPF DataGrid中设置垂直滚动条位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WPF中有一个数据网格,它有很多记录,因此具有VerticalScrollBar,当我在屏幕底部的某些位置执行诸如删除之类的活动时,在此活动之后设置了该行的第一个索引,即第一行已选择,但滚动条保持在相同位置(底部)。我希望它位于顶部或所选行的任何位置。

I've a datagrid in WPF, It has lots of records hence having a VerticalScrollBar, when i do some activity like delete in some where at bottom of the screen and after this activity set the first index of the row, First row has been selected but scrollbar remains at the same position(bottom). I want it to be at the top or wherever the selected row is.

谢谢

推荐答案

执行删除后,可以结合使用UpdateLayout和ScrollIntoView DataGrid方法。确保在调用ScrollIntoView方法之前先调用UpdateLayout方法。

After you perform the delete, you can use a combination of UpdateLayout and ScrollIntoView DataGrid methods. Ensure you call the UpdateLayout method before calling the ScrollIntoView method.

这篇关于在WPF DataGrid中设置垂直滚动条位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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