title: Attached Event? How to remove ScrollChanged event handler for WPF DataGrid at runtime
body: <p>The <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid%28v=VS.100%29.aspx" rel="nofollow">WPF DataGrid</a> class (Not the Windows Forms DataGrid!) can be set up to automatically handle scrolling without an external ScrollViewer and it's possible to register an event handler for the control's <em>internal</em> scrollbar by writing XAML like such:</p>
  
  <pre><code>&lt;DataGrid ScrollViewer.ScrollChanged="dGrid_ScrollChanged"  /&gt;
  </code></pre>
  
  <p>Correct me if I'm wrong but in this case, the internal ScrollViewer appears to be some kind of undocumented attached property. ScrollViewer is not a public field of DataGrid and you will find no reference to either ScrollViewer or the ScrollChanged event in the DataGrid documentation. In other words simply doing <code>myDataGrid.ScrollViewer.ScrollChanged += dGrid_ScrollChanged</code> doesn't work.</p>
  
  <p>So my question is, how does one go about adding or removing an event handler for this ScrollChanged event at runtime? I'm trying to understand what's going on here as much as I'm trying to solve the problem so the more explanation the better.</p>