void OnPointerReleased(object sender, PointerEventArgs e) { if (!e.CurrentPoint.IsLeftButtonPressed) { AssociatedElement.ReleaseCapture(); } }
private void Center() { if (content != null && AssociatedElement.ExtentWidth > 0 && AssociatedElement.ExtentHeight > 0 && AssociatedElement.ActualWidth > 0 && AssociatedElement.ActualHeight > 0) { AssociatedElement.CenterViewport(); } }
/// <summary> /// Called after the behavior is attached to an AssociatedObject. /// </summary> /// <remarks>Override this to hook up functionality to the AssociatedObject.</remarks> protected override void OnAttached() { callbackToken = AssociatedElement.RegisterPropertyChangedCallback(ContentControl.ContentProperty, ContentChanged); Initialize(); Center(); }
void OnTap(object sender, PointerEventArgs e) { var sb = new StringBuilder(); sb.AppendLine(string.Format("{0} '{1}'", AssociatedElement.GetType(), AssociatedElement.Name)); sb.AppendLine(string.Format("\tPosition: ({0}, {1})", AssociatedElement.Position.X, AssociatedElement.Position.Y)); LogEvent.UserInterface.Info(sb.ToString()); }
void OnPointerPressed(object sender, PointerEventArgs e) { if (e.CurrentPoint.IsLeftButtonPressed) { offset = new Vector3(e.CurrentPoint.Position, 0) - AssociatedElement.AbsolutePosition; AssociatedElement.CapturePointer(); } }
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); }
protected override void Scroll() { if (AssociatedElement != null && ItemInView != null) { var list = AssociatedElement.ItemsSource as IList; if (list != null && list.IndexOf(ItemInView) != -1) { this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (ItemInView != null) { AssociatedElement.ScrollIntoView(ItemInView, ScrollIntoViewAlignment.Leading); ItemInView = null; } }); } } else { base.Scroll(); } }
private void ScrollViewerBringIntoViewBehavior_GotFocus(object sender, RoutedEventArgs e) { var parent = AssociatedObject.FindParent <ScrollViewer>(); if (parent == null) { return; } var visibleBounds = AssociatedElement.TransformToVisual(Window.Current.Content).TransformBounds(new Rect(new Point(0, 0), AssociatedElement.RenderSize)); if (AssociatedElement.RenderSize.Width < parent.RenderSize.Width && AssociatedElement.RenderSize.Height < parent.RenderSize.Height) { double dx = 0; double dy = 0; if (visibleBounds.Left < 0) { dx = visibleBounds.Left; } else if (visibleBounds.Right > parent.RenderSize.Width) { dx = visibleBounds.Right - parent.RenderSize.Width; } if (visibleBounds.Top < 0) { dy = visibleBounds.Top; } else if (visibleBounds.Bottom > parent.RenderSize.Height) { dy = visibleBounds.Bottom - parent.RenderSize.Height; } parent.ChangeView(parent.VerticalOffset + dy, parent.HorizontalOffset + dx, null, false); } }
protected override void ElementAttached() { base.ElementAttached(); _watcher = AssociatedElement.WatchProperty(PropertyName, OnPropertyChanged); }
/// <summary> /// Called when the behavior is being detached from its AssociatedObject, but before it has actually occurred. /// </summary> /// <remarks>Override this to unhook functionality from the AssociatedObject.</remarks> protected override void OnDetaching() { AssociatedElement.UnregisterPropertyChangedCallback(ContentControl.ContentProperty, callbackToken); Release(); }
private void InputPane_Showing(InputPane sender, InputPaneVisibilityEventArgs args) { AssociatedElement.BringChildElementIntoView(args); }