title: WPF overriding ScrollVIewer in Listbox
body: <p>I made a class named "AniScrollViewer," it can set the vertical scroll offset<br>
  to animate Scrollviewer code-behind.<br></p>
  
  <pre><code>public class AniScrollViewer : ScrollViewer {
      public static readonly DependencyProperty CurrentVerticalOffsetProperty =
          DependencyProperty.Register("CurrentVerticalOffset", typeof(double), typeof(AniScrollViewer),
          new PropertyMetadata(new PropertyChangedCallback(OnVerticalChanged)));
  
      public double CurrentVerticalOffset {
          get { return (double)GetValue(CurrentVerticalOffsetProperty); }
          set { SetValue(CurrentVerticalOffsetProperty, value); }
      }
  
      private static void OnVerticalChanged(DependencyObject property, DependencyPropertyChangedEventArgs e) {
          AniScrollViewer viewer = property as AniScrollViewer;
          viewer.ScrollToVerticalOffset((double)e.NewValue);
      }
  }
  </code></pre>
  
  <p>I want to push this 'AniScrollViewer' into a Listbox</p>
  
  <p>I meet couple of problems:</p>
  
  <ul>
  <li>The Listbox class already has 'scrollviewer' inside. I want to replace <br>
  the default listbox scrollviewer with my custom AniScrollViewer, but I don't know how to do this.</li>
  <li>I want to get ScrollViewer in Listbox code-behind. Like this:<br></li>
  </ul>
  
  <p>Listbox listbox (this is already definded in XAML)<br>
  AniScrollViewer scrollviewer = listbox.~~~~;<br></p>
  
  <p>Please help.</p>