I have 2 Silverlight DataGrids one on top of another. I want to synchronize their horizontal scrollbars. I have tried to put them both in separate scrollviewers and set the horizontal offset of source scrollviewer to horizontal offset of target scrollviewer but that does not work, the below DataGrid scrollviewer disappers.I think that might be because these Datagrid are inside a StackPanel? I also tried to put these 2 grids in a third grid and apply scrollviewer on that but that does not work either
Does anyone have an idea how to go about this? Thanks a lot in advance
I did this in SL4, have no idea if it works in SL3, sorry. The docs state that the API is there but I have not tried it.
The trick is to use automation peers. Get the scroll pattern automation peers for both grids. When scrolling happens on one grid, scroll the other one through the automation peer.
To make this more concrete, assuming we have 2 grids, named _dgGrowth and _dgTotals:
What is not shown is setting up the Loaded event to OnPageLoaded and the Descendants() method found in this question.