title: Custom ToggleButton doesn't respond to ManipulationCompleted event
body: <p>I have a custom UI element that inherits from <code>System.Windows.Controls.Primitives.ToggleButton</code>. I'm also routing my mouse events through a custom <code>TouchDevice</code> that raises touch events instead.</p>
  
  <p>For some reason, the ManipulationCompleted event never fires. First, the custom TouchDevice can be found here: <a href="http://blakenui.codeplex.com/SourceControl/changeset/view/67526#Blake.NUI.WPF/Touch/MouseTouchDevice.cs" rel="nofollow noreferrer">http://blakenui.codeplex.com/SourceControl/changeset/view/67526#Blake.NUI.WPF/Touch/MouseTouchDevice.cs</a></p>
  
  <p>Here are the relevant parts of my class:</p>
  
  <pre><code>public class ToggleSwitch: ToggleButton {
  
      private Grid _root;
      private readonly IList&lt;int&gt; _activeTouchDevices;
      private const double UNCHECKED_TRANSLATION = 0;
  
      private TranslateTransform _backgroundTranslation;
      private TranslateTransform _thumbTranslation;
      private Grid _root;
      private Grid _track;
      private FrameworkElement _thumb;
      private double _checkedTranslation;
      private double _dragTranslation;
      private bool _wasDragged;
      private bool _isDragging;
  
      public override void OnApplyTemplate()
      {
              ...
              MouseTouchDevice.RegisterEvents(_root);
  
              _root.IsManipulationEnabled = true;
              _root.TouchDown += OnTouchDown;
              _root.TouchUp += OnTouchUp;
              _root.GotTouchCapture += OnGotTouchCapture;
              _root.LostTouchCapture += OnLostTouchCapture;
  
              _root.ManipulationStarted += OnManipulationStarted;
              _root.ManipulationDelta += OnManipulationDelta;
              _root.ManipulationCompleted += OnManipulationCompleted;
      }
  
      private void OnTouchDown(object sender, TouchEventArgs e)
      {
          e.TouchDevice.Capture(_root);
      }
  
      private void OnGotTouchCapture(object sender, TouchEventArgs e)
      {
          if (e.TouchDevice.Captured == _root)
          {
              Manipulation.AddManipulator(_root,e.TouchDevice);
              _activeTouchDevices.Add(e.TouchDevice.Id);
          }
      }
  
      private void OnManipulationStarted(object sender, ManipulationStartedEventArgs e)
      {
          e.Handled = true;
          _isDragging = true;
          _dragTranslation = Translation;
          ChangeVisualState(true);
          Translation = _dragTranslation;
      }
  
      private void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
      {
          e.Handled = true;
          var horizontalChange = e.DeltaManipulation.Translation.X;
          var direction = Math.Abs(horizontalChange) &gt;= Math.Abs(e.DeltaManipulation.Translation.Y) ? Orientation.Horizontal : Orientation.Vertical;
          if (direction == Orientation.Horizontal &amp;&amp; horizontalChange != 0.0)
          {
              _wasDragged = true;
              _dragTranslation += horizontalChange;
              Translation = Math.Max(UNCHECKED_TRANSLATION, Math.Min(_checkedTranslation, _dragTranslation));
          }
      }
  
      private void OnManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
      {
          e.Handled = true;
          _isDragging = false;
          var click = false;
          if (_wasDragged)
          {
              var edge = (IsChecked ?? false) ? _checkedTranslation : UNCHECKED_TRANSLATION;
              if (Translation != edge)
              {
                  click = true;
              }
          }
          else
          {
              click = true;
          }
          if (click)
          {
              OnClick();
          }
  
          _wasDragged = false;
      }
  
  }
  </code></pre>
  
  <p>The OnManipulationCompleted method is never entered.</p>