Facebook prevent auto scroll comment

broken image
broken image

The crux of the solution is to find and keep a reference to the ScrollViewer which manages the DataGrid's scroll position, and attach to it a handler which will be called when the scroll position changes. This is one such work-around, blessedly short, designed to fix the specific problem where you have a DataGrid containing columns extending offscreen, and you don't want the grid's horizontal scroll position to change because the user clicked on the 'wrong' cell in order to select the full row. WPF has many rough edges which make it difficult for beginners to use-and which often require projects to include mountains of work-around code to do things that should be trivial.

broken image