title: WPF: Accessing children elements from a base class
body: <p>I'm trying to create add some custom behaviors to a <code>ScrollViewer</code> in WPF / XAML.  Specifically, the <code>ScrollViewer</code> should scroll to the top any time the <code>Thumb</code> in the <code>VerticalScrollBar</code> is clicked.  Likewise, it should scroll to the left any time the <code>Thumb</code> in the <code>HorizontalScrollBar</code> is clicked.</p>
  
  <p>I would think the easiest way of doing this would be to create a new class that inherits from <code>ScrollViewer</code>, and then subscribes to the <code>MouseDoubleClick</code> event on the <code>VerticalScrollBar</code>'s <code>Thumb</code> and on the <code>HorizontalScrollBar</code>'s <code>Thumb</code>.</p>
  
  <p>For example:</p>
  
  <pre><code>public class DoubleClickScrollViwer : ScrollViewer
  {
     public DoubleClickScrollViwer()
        : base()
     {
        //Find the Horizontal and Vertical scroll bars.  Subscribe to the thumb's double click.
     }
  
     void VerticalScrollBarThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
     {
        this.ScrollToTop();
     }
  
     void HorizontalScrollBarThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
     {
        this.ScrollToLeft();
     }
  }
  </code></pre>
  
  <p>I can't seem to find a way to drill down to the children from the <code>DoubleClickScrollViewer</code>.  How can I drill down to the children?  Or is there a better way of going about this?</p>