Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
301 views
in Technique[技术] by (71.8m points)

c# - How to scroll a DataGrid using scrollviewer of another DataGrid

I have two datagrids. Vertical scrollbar of first datagrid is hidden. Required scenario is that I want to make the first datagrid scroll its content whenever the second datagrid is scrolled. User cannot scroll the first datagrid manually but whenever the second datagrid is scrolled, the first datagrid should move in parallel with it.

I tried to change the value of vertical scrollbar of first datagrid as the value of second datagrid's vertical scrollbar changes but this simply changes the position of the scrollbar but does not scroll the content of the datagrid.

How to synchronize the scroll bar of first datagrid with the second one? It should look like as if both are a part of same UI element and thus scrollbar should ideally scroll both.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In WPF, I think you can use the method of:

DataGrid.ScrollIntoView(object item, DataGridColumn column);

to set the position of the DataGrid.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...