private void AssociatedElement_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
        {
            AssociatedElement.ManipulationMode = ManipulationModes.None;

            if (movingOperation != null)
            {
                movingOperation.Complete();
                movingOperation = null;
            }

            scrollViewer = null;
        }
        private void AssociatedElement_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
        {
            scrollViewer = AssociatedElement.FindParent <ScrollViewer>();

            if (movingOperation != null)
            {
                movingOperation.Cancel();
                movingOperation = null;
            }

            if (scrollViewer != null)
            {
                movingOperation = AcquireOperation(e.Position.ToVector2());
            }
        }
        private NodeMovingOperation AcquireOperation(Vector2 position)
        {
            var mindmap = AssociatedElement.FindParent <Mindmap>();

            if (mindmap?.Renderer == null)
            {
                return(null);
            }

            var result = mindmap.Renderer.HitTest(position);

            if (result != null && result.RenderNode != mindmap.TextEditingNode)
            {
                return(NodeMovingOperation.Start(mindmap, result.RenderNode));
            }

            return(null);
        }