Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...