/// <summary> /// Initialize the behavior /// </summary> protected override void OnAttached() { base.OnAttached(); this.manipulationProcessor = new ManipulationProcessor2D(SupportedManipulations); this.manipulationProcessor.Started += OnManipulationStarted; this.manipulationProcessor.Delta += OnManipulationDelta; this.manipulationProcessor.Completed += OnManipulationCompleted; this.inertiaProcessor = new InertiaProcessor2D(); this.inertiaProcessor.TranslationBehavior.DesiredDeceleration = Deceleration; this.inertiaProcessor.RotationBehavior.DesiredDeceleration = AngularDeceleration; this.inertiaProcessor.ExpansionBehavior.DesiredDeceleration = ExpansionDeceleration; this.inertiaProcessor.Delta += OnManipulationDelta; this.inertiaProcessor.Completed += OnInertiaCompleted; this.inertiaTimer = new DispatcherTimer(); this.inertiaTimer.Interval = TimeSpan.FromMilliseconds(30); this.inertiaTimer.Tick += OnTimerTick; this.AssociatedObject.RenderTransformOrigin = new Point(0.5, 0.5); Move(new Point(0, 0), 0, 100); IsPivotActive = true; this.AssociatedObject.MouseLeftButtonUp += OnMouseUp; this.AssociatedObject.MouseLeftButtonDown += OnMouseDown; this.AssociatedObject.MouseMove += OnMouseMove; this.AssociatedObject.LostMouseCapture += OnLostMouseCapture; TouchHelper.AddHandlers(this.AssociatedObject, new TouchHandlers { TouchDown = OnTouchDown, CapturedTouchReported = OnCapturedTouchReported, }); TouchHelper.EnableInput(true); this.AssociatedObject.Loaded += (s1, e1) => { TouchHelper.SetRootElement(TouchHelper.GetRootElement(this.AssociatedObject)); }; }
/// <summary> /// Initialize the TouchHelper /// </summary> void AssociatedObjectLoaded(object sender, RoutedEventArgs e) { TouchHelper.SetRootElement(TouchHelper.GetRootElement(AssociatedObject)); }