开发者

ScrollBar on DataGrid keeps jumping back to the top

I am working with a WPF MVVM solution where I have a grid that is being updated multiple times every second. I need to allow the user the ability to scroll halfway down the grid and to remain there in between grid data updates. Right now if I scroll down the grid, the scrollbar position will jump back to the top as soon as the next time the grid's da开发者_如何学Cta is updated.

How can I accomplish keeping the x position of my scrollbar in its current location even when updates are processed. Please let me know.


Are you replacing/resetting the collection the datagrid is bound to in your updates or are you modifying the collection? I believe the grid will reset if you do something like myCollection = UpdatedCollection as opposed to modifying your collection using myCollection.Add(x) and myCollection.Remove(x)


<ListBox ScrollViewer.VerticalScrollBarVisibility="Visible" 
 ScrollViewer.CanContentScroll="False"/>

will should resolve this problem. The reason is normally that the ListView always goes to the last selected element. Also you need to make sure that the list is being populated by binding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜