开发者

Silverlight datagrid synchronized scrolling

I have two silverlight (2 or 3) datagrids (from the July 2009 Silverlight toolkit) positioned one on top of the other. The top datagrid holds values, the bottom datagrid holds summary values (e.g. total). I want their respective columns to be aligned at all times, even as the user changes the co开发者_StackOverflow中文版lumn header widths, column order, and as the user scrolls horizontally. How can this be done?

I'm using two datagrids because I want the total values in the lower datagrid to be visible at all times, as the user scrolls the contents of the top datagrid vertically.

I've tried to access the horizontal scrollbar of the datagrid using GetVisualDescendants(), but this returns no elements. How can this be done? I'm guessing it can be done because Silverlight Spy shows the visual hierarchy.


I'd suggest you put both of them inside a grid with the width set to the width of the grids. Then put that grid inside of a scroll viewer. Then you will have a single scrollbar at the bottom that will scroll both grids.

If you really want two scrollbars then use the method above but put them both in scroll viewers and attach to the OnScroll event. Then you can use the values from that event to programatically scroll the other scroll viewer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜